C# 调用api 问题

RainStarNetwork RainStarNetwork 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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() ;
}
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
RainStarNetwork
C# 111,128 成员 642,537 内容