Win32Api USB SetupDiGetDeviceInterfaceDetail fail

前端 未结 2 1325
眼角桃花
眼角桃花 2021-01-07 03:51

I am attempting to connect to a USB GPS device. I can successfully connect to the device if I manually create a file via CreateFile WinApi (using the path specified in Devi

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-07 04:33

    Congratulations, it is working. You'll get a Unicode string, it's twice as long. And a FALSE return is correct. You just need to call Marshal.GetLastWin32Error() and verify that you got ERROR_INSUFFICIENT_BUFFER. Your C code is broken, probably because you forgot to initialize theBytesReturned to zero.

提交回复
热议问题