How can 32-bit application find the location of 64-bit Program Files directory on Windows Vista 64-bit?

前端 未结 4 493
鱼传尺愫
鱼传尺愫 2021-01-12 02:31

I\'m struggling with a problem of how to determine the location of the 64-bit Program Files directory on 64-bit Windows Vista from a 32-bit application.

Calls to

4条回答
  •  余生分开走
    2021-01-12 03:11

    FOLDERID_ProgramFilesX64 is supported...

    MSDN says it is supported, but Microsoft's "WOW64" best practices document says it is not. See http://download.microsoft.com/download/A/F/7/AF7777E5-7DCD-4800-8A0A-B18336565F5B/wow64_bestprac.docx

    To quote:

    • Some variables work only if the process is 64-bit. For example, FOLDERID_ProgramFilesX64 does not work for 32-bit callers. In versions of Windows earlier than Windows 7, %ProgramW6432% did not work in the context of 32-bit processes. An application must determine whether it is running in a 64-bit process before it uses these variables.

    Under Windows 7 x64, running a 32-bit app in the Visual Studio debugger, I also get a return code of 0x80070002 (and a NULL pointer). Running the same code compiled as 64-bit returns the value S_OK and the path is properly filled in.

    I've used the registry hack as listed above since I can't find any other workaround.

提交回复
热议问题