C# 调用api 问题
c#通过调用api访问usb设备
其中调用DeviceIoControl函数时总是返回错误号87,意味着参数错误,请问是什么问题呢?谢谢,代码如下
[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool DeviceIoControl(
IntPtr hDevice,
uint dwIoControlCode,
ref long InBuffer,
int nInBufferSize,
ref long OutBuffer,
int nOutBufferSize,
ref int pBytesReturned,
ref NativeOverlapped lpOverlapped);
private long ResetPort(IntPtr hDevice)
{
int outByte = 0;
System.Threading.NativeOverlapped overlapped = new System.Threading.NativeOverlapped();
overlapped.InternalLow = IntPtr.Zero;
overlapped.InternalHigh = IntPtr.Zero;
overlapped.OffsetLow = 0;
overlapped.OffsetHigh = 0;
overlapped.EventHandle = CreateEvent(IntPtr.Zero, true, false, null);
long inbuffer = 0;
DeviceIoControl(hDevice, IOCTL_SCSI_PASS_THROUGH_DIRECT, ref inbuffer, 0, ref inbuffer, 0, ref outByte, ref overlapped);
return Marshal.GetLastWin32Error() ;
}