简体   繁体   English

如何使用InnoSetup安装驱动程序?

[英]How can I install a driver using InnoSetup?

I'd like to install a driver for a serial port using InnoSetup. 我想使用InnoSetup为串口安装驱动程序。 I have the inf file, and I can install the driver manually through device manager, but I'd like to be able to include the driver in my installer so that users don't have to go through the trouble of installing the driver themselves. 我有inf文件,我可以通过设备管理器手动安装驱动程序,但我希望能够在我的安装程序中包含驱动程序,以便用户不必经历自己安装驱动程序的麻烦。

See InstallHinfSection on MSDN. 请参阅MSDN上的InstallHinfSection The documentation also mentions how to invoke an installation by calling 'Rundll32.exe'. 该文档还提到了如何通过调用“Rundll32.exe”来调用安装。 Probably you'll end up with something like this: 可能你会得到这样的东西:

[Files]
..
Source: "driver\my_x86driver.inf"; DestDir: {app}\driver;
Source: "driver\my_x86driver.sys"; DestDir: {app}\driver;

[Run]
..
Filename: {sys}\rundll32.exe; Parameters: "setupapi,InstallHinfSection DefaultInstall 128 {app}\driver\my_x86driver.inf"; WorkingDir: {app}\driver; Flags: 32bit;


Note that you might need to run the setup in 64bit mode in 64bit systems to be able to install the driver: 请注意,您可能需要在64位系统中以64位模式运行安装程序才能安装驱动程序:

[Setup]
..
ArchitecturesInstallIn64BitMode=x64 

Also you can put checks as to run the version of .inf file depending on machine architecture (eg Check: Is64BitInstallMode ). 您还可以根据机器架构放置检查以运行.inf文件的版本(例如, Check: Is64BitInstallMode )。

This is a better answer: Inno setup: install drivers with rundll32 or dpinst? 这是一个更好的答案: Inno设置:使用rundll32或dpinst安装驱动程序?

Using InstallHinfSection on Windows 7 and beyond seems to be either broken or fraught with difficulty. 在Windows 7及更高版本上使用InstallHinfSection似乎要么已经破解,要么充满困难。 Making it work from a batch file is difficult, making it work from innosetup is even more difficult. 从批处理文件开始工作很困难,因为使用innosetup工作更加困难。 DPINST seems preferable, and is simpler. DPINST似乎更可取,而且更简单。

I used dpinst like this: 我用过这样的dpinst:

 [Files]    
Source: "Source\dpinst\dpinst32.exe"; DestDir: "{app}\driver"; DestName: dpinst.exe; Check: not IsWin64; Flags: ignoreversion
Source: "Source\dpinst\dpinst64.exe"; DestDir: "{app}\driver"; DestName: dpinst.exe; Check: IsWin64; Flags: ignoreversion

[Run]
Filename: "{app}\driver\dpinst.exe"; Parameters: "/A /LM";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM