Skip to content
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

SC_HANDLE missing is_null() #1385

Closed
Huntragon opened this issue Dec 14, 2021 · 3 comments
Closed

SC_HANDLE missing is_null() #1385

Huntragon opened this issue Dec 14, 2021 · 3 comments

Comments

@Huntragon
Copy link

I was updating a project that uses this crate to register and run an executable as a service in windows, and I ran into the issue that SC_HANDLE (returned from OpenServiceA) does not implement is_null() to see if the call executed successfully (which it did in the version I had before, 0.18.0).
As a workaround, I tried to do what the windows API says, to check if the return value is NULL (in which case it's not a valid handle). I've checked to see if there is a NULL constant defined somewhere and couldn't find it, so I'm guessing for now I have to use 0 directly (which I assume is what NULL means in the windows API, I don't have much experience with the API directly, only through the Rust crate)

@kennykerr
Copy link
Collaborator

SC_HANDLE is now just a type alias for isize consistent with the underlying Win32 definition. You can therefore just compare against 0 as that is the equivalent of NULL.

@travispaul
Copy link

For future travelers as of 0.30 SC_HANDLE has an is_invalid() method 🚀

@tim-weis
Copy link
Contributor

tim-weis commented Feb 2, 2022

This is true for the windows crate (SC_HANDLE) that restored newtypes for handles as of #1423 with version 0.30.0. In the windows-sys crate SC_HANDLE remains a type alias for isize and Kenny's comment above still applies here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants