C++ – Translating 32-bit paths to their WOW64 equivalents

cmfcwindowswow64

Is there any function that I can call to in a 32-bit app that would convert the paths that it thinks it's using to and from the paths that it's actually using? (For instance, call it to convert the path for a folder in Program Files to a path in Program Files (x86) or vice versa when running on a 64-bit system.) I need to do this so that, when the user is presented with a directory in the GUI (as when browsing for files or directories), he sees the real directory, rather than what the app itself thinks it sees.

We need to support both 32- and 64-bit Windows, so this should work in both environments.

Edit The need to deal with WOW64 lies in the fact that my app is the bootstrap application of an installer. By default, the product is installed under Program Files on a 32-bit system, while on a 64-bit system, it's installed under Program Files (x86). The dialogue that lets the user choose where to install the product (including on a different hard drive altogether if that's what he wants or needs); and it must work properly in both environments. Currently, it's always displaying (and browsing in) Program Files, even on 64-bit systems.

Best Answer

Is browsing through Program Files and Windows\System32 a use-case for your app? I encourage you to abandon solving this problem, as it gets really ugly. Either stay all in the 32-bit world, or recompile for x64. Living in the "in-between" world of WOW64 will make your code much more complex.

If you really want to do this, http://msdn.microsoft.com/en-us/library/aa365743(VS.85).aspx will do the trick.