I need for my program to determine if it was compiled for 32 bit windows or 64 bit/any CPU. I need to choose a different COM server flag depending on the compilation options. Any ideas?
Right-click on it or press and hold and then select Properties. Then go to the Compatibility tab. Here, check the "Run this program in compatibility mode for" box, and open the drop-down list. If the list starts with Windows Vista, then the application you selected is a 64-bit application.
So we need to use the Is64BitOperatingSystem property of the Environment class. This property is used to check whether the running operating system is based on 64-Bit architecture or not and returns true if it is 64-bit OS otherwise it will return false.
Checking at run time if you are running a 64-bit application:
To see whether your process is 64-bit or 32-bit you can simply check the IntPtr.Size or any other pointer type. If you get 4 then you are running on 32-bit. If you get 8 then you are running on 64-bit.
What type of computer is your process running as:
You can check the PROCESSOR_ARCHITECTURE environment variable to see if you are running on an x64, ia64 or x86 machine.
Is your process running under emulation:
The Win32 API IsWow64Process will tell you if you are running a 32-bit application under x64. Wow64 means windows32 on windows64.
Contrary to what other people have posted: IsWow64Process will not tell you if you are running a 32-bit or a 64bit application. On 32-bit machines it will tell you FALSE for 32-bit applications when run, and on a 64-bit machine it will tell you TRUE for a 32-bit application. It only tells you if your application is running under emulation.
Are you aware of Environment.Is64BitProcess
?
It determines whether the current running process is a 64-bit process.
You want the CORFLAGS command-line app from Microsoft. http://msdn.microsoft.com/en-us/library/ms164699(VS.80).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With