ProgramFilesX86
will always return the Program Files (x86)
folder path while ProgramFiles
will return the same path if your app is running in a 32-bit process and the Program Files
folder path if your app is running in a 64-bit process.
If you target the x86 platform then your app will always run in a 32-bit process, meaning that it won't run on an OS that doesn't support 32-bit processes.
If you target the x64 platform then your app will always run in a 64-bit process, meaning that it won't run on an OS that doesn't support 64-bit processes.
If you target the AnyCPU platform and check the Prefer 32-bit
box then your app will run in a 32-bit process if it can, otherwise it will run in a 64-bit process.
If you target the AnyCPU platform and uncheck the Prefer 32-bit
box then your app will run in a 64-bit process if it can, otherwise it will run in a 32-bit process.
Your app would have been running in a 32-bit process because you checked the Prefer 32-bit
box - note that it is checked by default - so your app could only see the Program Files (x86)
folder, regardless of the OS. It doesn't make sense for 32-bit apps to do anything related to 64-bit processes.