windows mbbile 5.0 下使用DeviceIoControl 出现NotSupportedException 错误
源码如下:
DeviceControlCode deviceCC= new DeviceControlCode(DeviceType.Disk,0x709,DeviceMethod.Buffered,DeviceAccess.Any);
DeviceControlCode是一个自定义的结构体
IntPtr hDevice = CreateFile("DSK1:", GENERIC_READ + GENERIC_WRITE, 0, 0,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL + FILE_FLAG_OVERLAPPED,0);
CreateFile没有问题,编译也没有问题,运行到DeviceIoControl才会弹出NotSupportedException 错误
DeviceIoControl(hDevice, deviceCC.Code, null, 0, out sdInfo, 3000,ref bytesReturned, IntPtr.Zero)
[DllImport("CoreDll.dll")]
public static extern int DeviceIoControl(IntPtr hDevice, uint dwIoControlCode, byte[] lpInBuffer,
UInt32 nInBufferSize, out byte[] lpOutBuffer, Int32 nOutBufferSize, ref Int32 lpBytesReturned, IntPtr lpOverlapped);
不知道是不是参数有问题啊?如果有问题是哪里的问题呢?