문제

i need to install a device driver (INF file) through c#. I used the function UpdateDriverForPlugAndPlayDevices. However, it returns me FALSE, but the GetLastError() returns a value 0, which indicates Success message for the installation. Not sure if i am proceeding in the correct way or not. Can anyone help? Thanks in advance, P

도움이 되었습니까?

해결책

You should look at the source for devcon. It is available in the WDK and is exactly what you need. Specifically look for the way that devcon will install an INF file. I still use the Windows 7 WDK, and it's located at C:\WinDDK\7600.16385.1\src\setup\devcon.

You'll probably find it's using the SetupCopyOEMInf() function, which you should try using from your C# application too.

다른 팁

This simple code worked for me

    private void driverInstall()
    {

        var process = new Process();
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.CreateNoWindow = true;
        process.StartInfo.RedirectStandardOutput = true;
        process.StartInfo.RedirectStandardError = true;
        process.StartInfo.FileName = "cmd.exe";

        process.StartInfo.Arguments = "/c C:\\Windows\\System32\\InfDefaultInstall.exe " + driverPath; // where driverPath is path of .inf file
        process.Start();
        process.WaitForExit();
        process.Dispose();
        MessageBox.Show(@"ADB / Fastboot / Google Android Driver has been installed");
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top