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 SHGetFolderPath() 32 bit vs 64 bit nor does supressing the wow64 filesystem redirection before calling SHGetSpecialFolderPath

Community
  • 1
  • 1
Daniel Lopez
  • 3,297
  • 2
  • 30
  • 29

2 Answers2

2

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
  • 3,297
  • 2
  • 30
  • 29
  • See the MSDN article on [Known Folders](http://msdn.microsoft.com/en-us/library/bb776911%28v=vs.85%29.aspx) – MrBry Apr 20 '11 at 11:27
  • 1
    FOLDERID_ProgramFilesX64 does not work if the application is 32 bit on a 64 bit OS. However, the environment variable "ProgramFiles" works. – Marius Matioc Aug 12 '17 at 03:24
1

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
  • 7,638
  • 3
  • 39
  • 60
  • 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 Aug 21 '09 at 16:47
  • Microsoft really screwed up when they tried to hide all this stuff and hack things around. The obvious reason to get the 64-bit Program Files forlder is to find a 64-bit program! I.e. you might want to run it. There is no reason why a 32-bit program should NOT have access to this folder. There is also no reason why there should even be a separate Program Files folder, but that mistake is in the past. – swpalmer Mar 14 '14 at 16:06