views:

834

answers:

2

What happens if I use HGetFolderPath 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 exists?

Thanks in advanced.

+1  A: 

The different scenarios are described in this article on MSDN.

Scroll down to "FOLDERID_ProgramFiles"

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

Magnus Johansson
thnx :)
Roman M
A: 

I read this page and the MSDN article and changed my CSIDL_PROGRAM_FILES entries to CSIDL_PROGRAM_FILESx86, however, unfortunatly, after deployment I found out that this did not work on windows xp 32-bits. I tested it with two DLLs, dynamically loaded SHELL32 and SHFOLDER, and called SHGetFolderPathA - with this syntax:

dynamic_SHGetFolderPath(0, CSIDL_PROGRAM_FILESX86, 0, SHGFP_TYPE_CURRENT, szSpecialDir);

it returned an error with both dlls, on SHELL32, GetLastError() returned 0xB7 (file already exists); on SHFOLDER, GetLastError() returned 0x0583 (missing class).

If I just change CSIDL_PROGRAM_FILESX86 to CSIDL_PROGRAM_FILES both calls works fine.

Guess my solution will be to call the function with the appropriated value given the OS bit count (32/64).

Any insights would be appreciated, Thanks

Marcio S Monteiro