New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: LookupAccountNameW does not use Option for optional arguments #2111
Comments
Similar problem with RegQueryInfoKeyW for the pub unsafe fn RegQueryInfoKeyW<'a, P0>(hkey: P0, lpclass: ::windows::core::PWSTR,... |
This is a limitation where non-pointer parameters don't consider the optional metadata flag, but it probably should do so for handle types (they're not pointers but often contain pointers). |
Thanks a lot Kenny. Another idea that may help is also implementing the e.g. impl From<Option<PCWSTR>> for PCWSTR {
fn from(from: Option<PCWSTR>) -> Self {
from.unwrap_or_else(Self::null)
}
} Thanks heaps |
Same for |
All these parameters should now support |
Which crate is this about?
windows
Crate version
0.42.0
Summary
As per the docs, this function has various optional arguments:
BOOL LookupAccountNameW( [in, optional] LPCWSTR lpSystemName, [in] LPCWSTR lpAccountName, [out, optional] PSID Sid, [in, out] LPDWORD cbSid, [out, optional] LPWSTR ReferencedDomainName, [in, out] LPDWORD cchReferencedDomainName, [out] PSID_NAME_USE peUse );
However, these are not marked as such in the Rust crate:
Furthermore, PWSTR doesn't have a From implemntation from Option like PCWSTR so I'm left with something like this:
I would love to be able to call this function as follows instead (similar to various others):
Toolchain version/configuration
Reproducible example
Crate manifest
Expected behavior
lpSystemName, Sid and ReferencedDomainName should all be
Option<T>
s 😄Actual behavior
Currently, all parameters are marked as required even though several of them are optional.
Additional comments
I'm struggling to know where such issues originate (e.g. win32metadata vs windows-rs). I searched win32metadata for the definition of this function and others that have optional arguments but couldn't see a distinction, so I'm guessing this is handled within windows-rs? 😄
The text was updated successfully, but these errors were encountered: