How will my program decide to install in the "Program Files (x86)" section?

Just out of curiosity, if I create an installer, how can I decide which directory "Program Files" to install? On 32-bit systems, the environmental variable "% programfiles%" is good enough. However, on 64-bit systems, 32-bit programs should not be installed in this folder, but instead on "% programfiles (x86)%", which, as I understand it, points to "C: \ Program Files (x86)". My question is: how should the installer decide which environment variable to use? Will the value "% programfiles%" be changed for a 32-bit application, or should I first check if "% programfiles (x86)%" exists before using "% programfiles%", or should I do something completely different?

Thank! This is just out of my own curiosity as I try to get used to 64-bit operating systems.

+3
source share
2 answers

When a 32-bit program (the installer in your case) asks the system to resolve the constant ProgramFilePath(check the exact name in MSDN), the system will not return the C: \ Program files, but the C: \ Program files (x86). So this is a system that solves, not an application.

+4
source

I'm sure I read somewhere that Windows did this for you automatically. In other words, if your installer was 32-bit, it would be redirected to the directory option x86, even if you tried to install it in Program Files.

, The Old New Thing, , , .


, , , - Raymond Chen.

32- , , 64- (, -, ) 64- , 32- . : " x64 32- ?"

: " , ". 32- , , . 64- . 32- , 64- 64- . 64- 32- , , , 64- 64- .

+4

Source: https://habr.com/ru/post/1778506/


All Articles