我的程序应如何决定安装在“Program Files (x86)”下?
出于好奇,如果我正在创建程序安装程序,我应该如何决定安装到哪个“Program Files”目录?在 32 位系统上,环境变量“%programfiles%”就足够了。但是,在 64 位系统上,32 位程序不应安装到该文件夹,而应安装到“%programfiles(x86)%”,据我所知,它指向“C:\Program Files (x86)”。我的问题是:安装程序应如何决定使用哪个环境变量?对于 32 位应用程序,“%programfiles%”的值是否会改变,或者我应该在使用“%programfiles%”之前首先检查“%programfiles(x86)%”是否存在,或者我应该做一些完全不同的事情?
谢谢!这只是出于我自己的好奇心,因为我试图习惯 64 位操作系统。
Just out of curiosity, if I am creating a program installer, how should I decide in which "Program Files" directory to install to? On 32-bit systems, the environmental variable "%programfiles%" is good enough. However, on 64-bit systems, 32-bit programs should not install to that folder and instead to "%programfiles(x86)%", which as I understand points to "C:\Program Files (x86)". My question is: How should the installer decide which environment variable to use? Will the value of "%programfiles%" change for a 32-bit application, or should I always check first whether "%programfiles(x86)%" exists before using "%programfiles%", or should I do something entirely different?
Thanks! This is just out of my own curiosity, as I try to get used to 64-bit operating systems.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当 32 位程序(在您的情况下是安装程序)要求系统解析
ProgramFilePath
常量(在 MSDN 中检查确切名称)时,系统不会返回 C:\Program files,而是返回 C: \程序文件(x86)。所以决定的是系统,而不是应用程序。When the 32-bit program (installer in your case) asks the system to resolve the
ProgramFilePath
constant (check the exact name in MSDN), the system does not return C:\Program files, but C:\Program files(x86). So it's the system that decides, not the application.我很确定我在某处读到 Windows 会自动为您完成此操作。换句话说,如果您的安装程序是 32 位,即使您尝试安装到
Program Files
中,它也会被路由到x86
目录变体。我确定我在《旧新事物》上读过这篇文章,但是 这里有一个链接,它支持争用,直到我找到该链接。
啊,是的,在这里,来自非常有用的 Raymond Chen。
I'm pretty certain that I read somewhere that Windows did this for you automagically. In other words, if your installer was 32-bits, it would be routed to the
x86
directory variant even though you were trying to install intoProgram Files
.I'm sure I read this on The Old New Thing but here's a link that supports the contention until I can find that one.
Ah, yes, here it is, from the ever useful Raymond Chen.