SHGetFolderPath() 32 bit vs 64 bit

2019-08-02 03:12发布

What happens if I use SHGetFolderPath api call in a 32 bit system with CSIDL_PROGRAM_FILESx86 folder id instead of the CSIDL_PROGRAM_FILES id?

Theoretically CSIDL_PROGRAM_FILESx86 should map to C:\program files (x86) in a 64 bit system but what does it map to in a 32 bit system where this path doesn't exist?

2条回答
可以哭但决不认输i
2楼-- · 2019-08-02 03:52

The different scenarios are described in this article on MSDN.

Scroll down to remarks, "FOLDERID_ProgramFiles"

OS    Application KNOWNFOLDERID            Default Path                   CSIDL Equivalent  
32 bit    32 bit  FOLDERID_ProgramFiles    %SystemDrive%\Program Files    CSIDL_PROGRAM_FILES  
32 bit    32 bit  FOLDERID_ProgramFilesX86 %SystemDrive%\Program Files    CSIDL_PROGRAM_FILESX86  
32 bit    32 bit  FOLDERID_ProgramFilesX64 (undefined)    Not applicable  Not applicable

Summary: It will point to %SystemDrive%\Program Files

查看更多
Evening l夕情丶
3楼-- · 2019-08-02 04:08

Try this:

GetEnvironmentVariable("ProgramW6432", szBuffer, nBufferSize);

YMMV

查看更多
登录 后发表回答