سؤال


I'm trying to use UpdateDriverForPlugAndPlayDevices to install drivers but Im just Getting "No More Data Available" Error. Please help me

Code:

 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
هل كانت مفيدة؟

المحلول

Fix your PInvoke declaration.

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top