Click here to Skip to main content
11,642,216 members (61,157 online)
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 6: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 DamithSL 240
1 Sergey Alexandrovich Kryukov 184
2 Afzaal Ahmad Zeeshan 139
3 OriginalGriff 135
4 Mika Wendelius 80
0 Mika Wendelius 460
1 DamithSL 443
2 OriginalGriff 340
3 Afzaal Ahmad Zeeshan 228
4 Sergey Alexandrovich Kryukov 179

Advertise | Privacy | Mobile
Web03 | 2.8.150731.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