views:

499

answers:

2

Is there a way from a 32bit application running on a 64bit system to have access to the default folders for 64bit applications?

For example, using SHGetSpecialFolderPath with CSIDL_PROGRAM_FILES from a 32bit application returns "C:\Program Files (x86)' If the same call was used from a 64bit application, I would get "C:\Program Files". Is there a way of getting that "C:\Program Files" from a 32bit application?

A related question here does not help http://stackoverflow.com/questions/138379 nor does supressing the wow64 filesystem redirection before calling SHGetSpecialFolderPath

+1  A: 

Answering my own question, it seems it is not possible with SHGetSpecialFolderPath. In Vista and later, using the replacement function SHGetKnownFolderPath allows it with FOLDERID_ProgramFilesX64

Daniel Lopez
+1  A: 

I believe the whole reason for having separate folders was to prevent 32 and 64 bit applications from mixing. Therefore, you shouldn't need to see a folder belonging to a different bitness from your application.

You may have a very good reason, but I don't see one in your question as posted.

Brad Bruce
It is for a 32bit application that needs to perform installation related tasks for 32bit and 64bit applications on 32bit and 64bit systems. The exact same binary needs to be used in all systems (otherwise we could simply recompile). This is not a requirement we can change, unfortunately
Daniel Lopez