views:

37

answers:

2

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);
A: 

There is not a lot of data here to go on, but Marshal.GetLastWin32Error() should give you more specific error information.

Michael
A: 

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.