我正在尝试使用UpdateDriverForPlugAndPlayDevices安装驱动程序,但我只是遇到“没有更多可用数据”错误。请帮我
代码:
Const Driver_TEMP_Path As String = "C:\AdbDriver\android_winusb.inf"
Const INSTALLFLAG_FORCE = &H1
Const INSTALLFLAG_READONLY = &H2
Const INSTALLFLAG_NONINTERACTIVE = &H4
Const INSTALLFLAG_BITS = &H7
Private Declare Function sysUpdateDriverForPlugAndPlayDevices Lib "newdev.dll" Alias "UpdateDriverForPlugAndPlayDevicesA" (ByVal hwndParent As Long, ByVal HardwareId As String, ByVal FullInfPath As String, ByVal InstallFlags As Long, ByRef bRebootRequired As Boolean) As Boolean
Function InstallDeviceDriver(device As USBDeviceInfo, hwnd As Long) As Boolean
Dim result As Boolean
Dim RebootReuqired As Boolean
If Not My.Computer.FileSystem.FileExists(Driver_TEMP_Path) Then
MessageBox.Show("Bot fOUnd")
End If
result = sysUpdateDriverForPlugAndPlayDevices(hwnd, "USB\VID_0B05&PID_4C91&MI_01", Driver_TEMP_Path, INSTALLFLAG_FORCE, RebootReuqired)
If Not result Then
Dim errorCode As Integer = Err.LastDllError
Dim msg As String = "Unknown"
Select Case errorCode
Case 2
msg = "File Not Found"
Case 1004
msg = "Invald Flags"
Case 259
msg = "No More Data Available"
Case -536870389
msg = "No Such device"
End Select
MessageBox.Show(Err.LastDllError & ": " & msg)
End If
Return result
End Function
修正您的PInvoke声明。
Private Declare Auto Function sysUpdateDriverForPlugAndPlayDevices Lib "newdev.dll" Alias "UpdateDriverForPlugAndPlayDevices" (ByVal hwndParent As IntPtr, ByVal HardwareId As String, ByVal FullInfPath As String, ByVal InstallFlags As Integer, <Out()> ByRef bRebootRequired As Boolean) As Boolean
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句