How to judge a handle?
-
Hi, I have a windows handle which is returned by third party lib, this handle sometimes is valid, sometimes isn't. I want to know whether there is method or function to judge the validity of a handle? Thanks, Jeff Xi
GetHandleInformation()
-
GetHandleInformation()
Roman Fadeyev wrote: GetHandleInformation() Beware that function only works in Windows NT, it is not supported for Win9x OSs
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life! -
Hi, I have a windows handle which is returned by third party lib, this handle sometimes is valid, sometimes isn't. I want to know whether there is method or function to judge the validity of a handle? Thanks, Jeff Xi
There are ways, but it depends on the type of handle that you are dealing with. Do you have a window handle, a GDI handle, a file handle, or something else?
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life! -
Hi, I have a windows handle which is returned by third party lib, this handle sometimes is valid, sometimes isn't. I want to know whether there is method or function to judge the validity of a handle? Thanks, Jeff Xi
If it's a handle to a window, you can call IsWindow(). For other handles and Win98 compatibility, you could use DuplicateHandle() and check the error returns (don't forget to close the duplicated handle if successful.)