I have a Visual C# application that uses the WinUSB API to access USB devices.
The Winusb_Initialize function accepts a SafeFileHandle obtained with CreateFile and returns an InterfaceHandle defined as a PWINUSB_INTERFACE_HANDLE, which is "an opaque handle to the first interface on the device."
I've been using an IntPtr for the InterfaceHandle but would like to use a safe handle if possible. I tried SafeFileHandle without success.
Other than trying it out, is there a way to know whether the InterfaceHandle can use a custom safe handle deriving from SafeHandleZeroOrMinusOneIsInvalid or another SafeHandles class? How to know which class to use?
Winusb_Initialize:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff540277%28v=vs.85%29.aspx
winusb.h has:
typedef PVOID WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE;