如何选择处理器架构来使用 Delphi 安装 MSI
好消息:重大版本即将发布!
坏消息:我刚刚发现(晚了 2 周)有些人的计算机上没有 MSXML 6,而我们推出的新安装程序需要它。
好消息:我们可以分发一个 MSI 文件来安装 MSXML
坏消息:有 3 个 MSI 文件可供选择,一个是“正常”文件,一个以 ia64 结尾,一个以 x64 结尾。
我可以使用 Delphi 7、C++ 和嗯...批处理文件...我如何制作一个方便的 Setup.exe 来选择正确的 MSI 自动启动。
Good news: A major release is in the bag!
Bad news: I just found out (2 weeks too late) that some people don't have MSXML 6 on their machines and the new installer we're rolling out requires it.
Good news: We can distribute an MSI file to install MSXML
Bad news: There are three MSI files to choose from, one 'normal' one, one ending in ia64 and one ending in x64.
I have at my disposal, Delphi 7, C++ and um... Batch files... How do I make one of those handy Setup.exe's that choose the right MSI to launch automatically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短回答:使用
GetSystemInfo
Windows API 函数可查明系统是 32 位还是 64 位。示例代码:
两个最常见的输出是“Intel”(32 位 x86)和“AMD64”(64 位 x64)。事实上,您或多或少可以相信您会得到其中之一。
现在,实际上,我相信上面的程序将总是返回“Intel”(32位x86),因为所有Delphi应用程序都是32位的,因此它们是在64位Windows下模拟的(使用 WOW64)——Delphi 编译器和 IDE 没有 64 位版本。
因此,要获得系统的真实架构,无论仿真如何,您都必须使用
GetNativeSystemInfo
函数。该函数没有包装器,因此您必须自己从 kernel32.dll 导入它。Short answer: Use the
GetSystemInfo
function of the Windows API to find out if the system is 32-bit or 64-bit.Example code:
The two most common outputs are 'Intel' (32-bit x86) and 'AMD64' (64-bit x64). In fact, you can more or less trust that you will get one of those.
Now, in reality, I believe that the above program will always return 'Intel' (32-bit x86) because all Delphi applications are 32-bit, and so they are emulated under a 64-bit Windows (using WOW64) -- there is no 64-bit release of the Delphi compiler and IDE.
So to obtain the true architecture of the system, regardless of emulation, you have to use the
GetNativeSystemInfo
function. There is no wrapper for this function, so you have to import it yourself from kernel32.dll.您可以忘记用于 Itanium 系统的 IA64。
我会使用一个工具来创建设置(有一些优秀的免费工具,例如 InnoSetup)。他们将检测安装程序正在运行哪种类型的系统,并让您运行正确的 msxml 安装程序。如果该工具直接支持 Windows Installer 引擎,则它可以利用合并模块 (msm) 来分发所需的运行时,否则很容易从安装程序运行 msi。
您也可以编写自己的安装程序,但您需要另一个应用程序来编写、测试和维护。我会利用现有的来完成这样的任务。
You can forget the IA64 which is for Itanium systems.
I'd use a tool to create a setup (there are excellent free ones, like InnoSetup). They will detect which kind of system the setup up is running upon, and let you run the proper installer of msxml. If the tool supports the Windows Installer engine directly it can take advantage of merge modules (msm) to distribute needed runtimes, otherwise is pretty easy to run a msi from the installer.
You could also write your own installer, but you get another app to write, test and mantain. I'd take advantage of existing ones for such a task.