How do I install hardware driver using C++ on Win32?

主宰稳场 提交于 2019-12-11 05:25:31

问题


How do I install a hardware driver (inf file) using C++?

Platform : Win32


回答1:


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 call DriverPackageInstall(). The expected return value is ERROR_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() returns ERROR_IN_WOW64 and then call CreateProcess to start your 64 bits installer.




回答2:


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



来源:https://stackoverflow.com/questions/2277252/how-do-i-install-hardware-driver-using-c-on-win32

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!