如何使用 C++ 安装硬件驱动程序在 Win32 上?
如何使用 C++ 安装硬件驱动程序(inf 文件)?
平台:Win32
How do I install a hardware driver (inf file) using C++?
Platform : Win32
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该过程通常称为“预安装”。 (正常安装过程是由硬件设备到达触发的。)
相关函数可以在DDK的
中找到。您可能想要调用DriverPackageInstall()
。预期返回值为ERROR_NO_SUCH_DEVINST
[原文如此],因为目前还没有这样的设备。有一些 64 位的时髦之处:您无法从 Win32 应用程序安装 64 位驱动程序(至少在 XP/Vista/Windows7/2003/2008 中不能)。因此,您的 Win32 安装程序必须检查
DriverPackageInstall()
是否返回ERROR_IN_WOW64
,然后调用CreateProcess
来启动您的 64 位安装程序。The process is usually called pre-installation. (The normal install process is triggered by the arrival of an hardware device.)
The relevant functions can be found in
<DIFxAPI.h>
from the DDK. You probably want to callDriverPackageInstall()
. The expected return value isERROR_NO_SUCH_DEVINST
[sic] as there won't be such a device yet.There's some 64 bit funkyness: you can't install a 64 bits driver from a Win32 app (at least not in XP/Vista/Windows7/2003/2008). Hence, your Win32 installer must check if
DriverPackageInstall()
returnsERROR_IN_WOW64
and then callCreateProcess
to start your 64 bits installer.我会考虑使用 setupapi.dll 中的 InstallHinfSection 函数。以下是相关文档:
http://msdn.microsoft .com/en-us/library/aa376957%28VS.85%29.aspx
I would look at using the InstallHinfSection function, in the setupapi.dll. Here's the related docs:
http://msdn.microsoft.com/en-us/library/aa376957%28VS.85%29.aspx