In my C# code,DeviceIoControl is returning false,the handle is correct
开发者_运维百科DeviceIoControl(deviceHandle,
IOCTL_STORAGE_GET_DEVICE_NUMBER,
IntPtr.Zero,
0,
OutBuffPtr,//&psdn,
OutBuffSize,
ref dwBytesReturned,
IntPtr.Zero);
There is not a lot of data here to go on, but Marshal.GetLastWin32Error() should give you more specific error information.
I did try to use Marshal.GetLastWin32Error() which returned 1, according to MSDN it means incorrect function. In the code I am trying to get the device number passing Intptr to buffer of size STORAGE_DEVICE_NUMBER (which is 12 bytes) from function DeviceIoControl in kernel32.dll.
I've hit a dead end.
精彩评论