Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone!

We are having issues with getting the process.start commands to work properly on some computers. We want to take into account either 32 bit or 64 bit computers. How can we properly check for either one? This is the code we have so far.

C#
Process newproc = new Process();
newproc.StartInfo.FileName = Environment.GetEnvironmentVariable("PROGRAMFILES") + "\\Pico Technology\\TMS\\picoscope.exe";
            try
            {
                // Attempts to open PicoScope program
                newproc.Start();
            }
            catch (Exception ex)
            {
                //error message thrown
            }


Should this be the 32 bit folder on both 32 bit and 64 bit computers?
Posted

1 solution

If you've a 32-bit application, the environment variable will be the 32-bit Program Files folder. If you've a 64-bit application, the environment variable will be the 64-bit Program Files folder. And if you've a 64-bit application, but if you want to get the 32-bit Program Files folder, use this:
C#
string ProgramFilesX86 = Environment.GetEnvironmentVariable("PROGRAMFILES(X86)")


So, the value of the environment variable does not depend on the computer, but on the type of application (of course you can't run a 64-bit application on a 32-bit computer :-))
 
Share this answer
 
v2
Comments
joshrduncan2012 31-Oct-12 13:40pm    
If we do Environment.GetEnvironmentVariable("PROGRAMFILES") and our .exe file is a 32 bit program, we will get the 32-bit location on both 32 bit and 64 bit computers?
Thomas Daniels 31-Oct-12 13:41pm    
Yes!
I'm 100% sure, because I've a 64-bit computer, so I tested it.
joshrduncan2012 31-Oct-12 13:44pm    
Ok thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900