【发布时间】:2014-03-27 09:20:57
【问题描述】:
我需要通过 c# 安装设备驱动程序(INF 文件)。我使用了 UpdateDriverForPlugAndPlayDevices 功能。但是,它返回 FALSE,但 GetLastError() 返回值 0,表示安装成功消息。 不确定我是否以正确的方式进行。 任何人都可以帮忙吗? 提前致谢, P
【问题讨论】:
标签: c# installation device-driver inf getlasterror
我需要通过 c# 安装设备驱动程序(INF 文件)。我使用了 UpdateDriverForPlugAndPlayDevices 功能。但是,它返回 FALSE,但 GetLastError() 返回值 0,表示安装成功消息。 不确定我是否以正确的方式进行。 任何人都可以帮忙吗? 提前致谢, P
【问题讨论】:
标签: c# installation device-driver inf getlasterror
您应该查看devcon 的来源。它在 WDK 中可用,正是您所需要的。具体找devcon will install an INF file的方式。我仍然使用 Windows 7 WDK,它位于 C:\WinDDK\7600.16385.1\src\setup\devcon。
您可能会发现它是 using the SetupCopyOEMInf() function,您也应该尝试在 C# 应用程序中使用它。
【讨论】:
这个简单的代码对我有用
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");
}
【讨论】: