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

前端 未结 4 486
鱼传尺愫
鱼传尺愫 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:15

    As you mentioned, using SHGetKnownFolderPath from a 32-bit application will not work on a 64-bit operating system. This is because Wow64 emulation is in effect.

    You can however use RegOpenKeyEx passing in the flag KEY_WOW64_64KEY and then read the program files directory from registry.

    The location in registry:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion

    You are interested in the string value:

    ProgramFilesDir

提交回复
热议问题