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