Click here to Skip to main content
Rate this: bad
good
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";
            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 31-Oct-12 7:57am

1 solution

Rate this: bad
good
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 | :) )
  Permalink  
v2
Comments
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
   
Yes!
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 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 85
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 31 Oct 2012
Copyright © CodeProject, 1999-2014
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