相当于在 Windows XP 或更高版本中以编程方式从文件夹安装驱动程序
我需要在客户的计算机上安装驱动程序。不幸的是,现在执行此操作的唯一方法是让 Windows 在设备插入时显示其“硬件更新向导”,然后让用户执行以下操作:
- 选择“否,这次不”,
- 选择“从特定位置(高级)”,
- 选中或取消选中适当的复选框,然后选择包含驱动程序的文件夹
。所有这些对于不懂技术的用户来说都是缓慢且不友好的。对于必须在多台计算机上安装该设备的人来说,这也是一个重复且烦人的过程。
因此,我正在尝试编写一个非常简单的程序来提示用户插入设备。然后程序会自动执行上面相同的步骤。我的问题:
- 我想知道是否有一个 Windows API 可以在文件夹中查找驱动程序,因为这就是向导的作用。
- 我刚刚发现了 DriverPackageInstall 函数。将 .inf 文件作为参数传递会达到我想要的效果吗? (同时我将编写代码来测试这一点,请给我一些时间下载 Windows 驱动程序工具包并设置一个项目...)。
- 还有其他建议吗?
I need to have a driver installed in my customers' computers. Unfortunately, the only way to do this right now is having Windows show its "Hardware Update Wizard" when the device is plugged in, and then have the user do the following:
- select "No, not this time",
- select "Install from a specific location (Advanced)",
- check or uncheck appropriate checkboxes and select the folder that contains the drivers
All of which is slow and unfriendly for a non technically savvy user. For the people who must install the device in many computers, it's a repetitive and annoying process too.
So, I'm trying to write a very simple program that will prompt the user to plug in the device. Then the program will do the same steps above automatically. My questions:
- I wonder if there is a Windows API that looks for drivers in a folder, since that's what the Wizard does.
- I've just discovered the function
DriverPackageInstall
. Would passing the .inf file as a parameter do what I want? (I'll be writing code to test this in the meanwhile, just give me some time to download the Windows Driver Kit and set up a project...). - Any other suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您没有指定 Windows 的版本。
在 Windows 7 上,有 pnputil:
以编程方式,您可以使用
DiInstallDriver
You did not specify which version of Windows.
On Windows 7 there`s pnputil:
programmatically, you can use
DiInstallDriver
有多种方法,其中一些取决于您拥有的设备类型。
有多种用于安装驱动程序包的工具。
DpInst 是一个完整的应用程序,可以显示向导并可自定义安装驱动程序包
DifXApp 构建可用于安装驱动程序的 msi 包
DifxApi 是 DpInst 和 DifxApp 用于安装驱动程序的 API。
直接使用SetupApi函数。
这里的函数SetupCopyOEMInf和 UpdateDriverForPlugAndPlayDevices 提供相应的入口点用于驱动程序设置。这些包含在WinSDK 中。
DpInst/DifxApp/DifxApi 是 Windows 驱动程序工具包 (WDK) 的一部分。
There are several ways and some depend on the type of device you have.
There are several tools for installing driver packages.
DpInst is a complete application which can show a wizard and be customized to install a driver package
DifXApp builds a msi package which can be used to install drivers
DifxApi is the API which DpInst and DifxApp use to install drivers.
Directly using the SetupApi functions.
Here the functions SetupCopyOEMInf and UpdateDriverForPlugAndPlayDevices provide the corresponding entry points for a driver setup. These are contained in the WinSDK.
DpInst/DifxApp/DifxApi are part of the Windows Driver Kit (WDK).
DifX(在 Windows DDK 中找到)是 Microsoft 推荐的安装驱动程序的方法。 DPInst 是独立工具,DifX API 是编程方式。
如果驱动程序已签名,您可以使用 DPInst(或 DifX API)预安装它,然后用户插入硬件后就会安装它(没有任何向导或提示)。
如果驱动程序未签名(即没有签名的 .cat 文件),则:
DifX (found in the Windows DDK) is the Microsoft recommended way for installing drivers. DPInst is the standalone tool and DifX API is the programmatic way.
If the driver is signed, you can use DPInst (or DifX API) to preinstall it and then it'll be installed (without any wizards or prompts) as soon as the user inserts the hardware.
If the driver is unsigned (i.e. has no signed .cat file), then: