Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
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.
Process newproc = new Process();
newproc.StartInfo.FileName = Environment.GetEnvironmentVariable("PROGRAMFILES") + "\\Pico Technology\\TMS\\picoscope.exe";
                // Attempts to open PicoScope program
            catch (Exception ex)
                //error message thrown
Should this be the 32 bit folder on both 32 bit and 64 bit computers?
Posted 31-Oct-12 7:57am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:
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 Smile | :) )
joshrduncan2012 at 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?
ProgramFOX at 31-Oct-12 13:41pm
I'm 100% sure, because I've a 64-bit computer, so I tested it.
joshrduncan2012 at 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)

  Print Answers RSS
0 Zoltán Zörgő 265
1 /\jmot 205
2 CHill60 145
3 Peter Leow 145
4 CPallini 135
0 Sergey Alexandrovich Kryukov 9,363
1 OriginalGriff 6,881
2 Peter Leow 4,577
3 Zoltán Zörgő 4,184
4 CHill60 2,892

Advertise | Privacy | Mobile
Web02 | 2.8.150129.1 | Last Updated 31 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100