windows 如何使用 InnoSetup 安装驱动程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7405009/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I install a driver using InnoSetup?
提问by nathan
I'd like to install a driver for a serial port using 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.
我想使用 InnoSetup 为串行端口安装驱动程序。我有 inf 文件,我可以通过设备管理器手动安装驱动程序,但我希望能够在我的安装程序中包含驱动程序,这样用户就不必自己安装驱动程序。
回答by Sertac Akyuz
See InstallHinfSectionon MSDN. The documentation also mentions how to invoke an installation by calling 'Rundll32.exe'. Probably you'll end up with something like this:
请参阅MSDN 上的InstallHinfSection。该文档还提到了如何通过调用“Rundll32.exe”来调用安装。可能你最终会得到这样的结果:
[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 (e.g. Check: Is64BitInstallMode
).
您也可以根据机器架构(例如Check: Is64BitInstallMode
)检查运行 .inf 文件的版本。
回答by quickly_now
This is a better answer: Inno setup: install drivers with rundll32 or dpinst?
这是一个更好的答案:Inno setup: install drivers with rundll32 or dpinst?
Using InstallHinfSection on Windows 7 and beyond seems to be either broken or fraught with difficulty. Making it work from a batch file is difficult, making it work from innosetup is even more difficult. DPINST seems preferable, and is simpler.
在 Windows 7 及更高版本上使用 InstallHinfSection 似乎已被破坏或充满困难。让它从批处理文件工作很困难,让它从 innosetup 工作更困难。DPINST 似乎更可取,而且更简单。
回答by Michael Richardson
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";