开发者

Launching 64-bit executable from 32-bit Windows app

What is the "correct" way for a 32-bit application to find the "Program Files" folder on 64-bit Windows? For example, I am running a 32-bit application with a VBScript engine, and want to launch 64-bit Excel (using ShellExec, or similar). In the 32-bit world, I would check the environment variable "ProgramFiles" to get the base folder. My understanding is that as a 32-bit app on a 64-bit Windows, that environment variable will point to the 32-bit program files folder - eg: C:\Program Files(x86). But my 64-bit Excel will be under C:\Program Files.

I want开发者_Go百科 to avoid hard-coding a reference to "c:\program files".


You can check the environment variable "ProgramW6432". It should exist and point to Program Files, without the x86, when running a 32bit application on a 64bit Windows.

Documentation: MSDN


Depending on the version of windows, you should be using the known folders apis.

http://msdn.microsoft.com/en-us/library/bb776911%28v=VS.85%29.aspx

Specifically you can use FOLDERID_ProgramFilesX64 in conjunction with SHGetKnownFolderPath.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜