Click here to Skip to main content
13,045,790 members (45,765 online)
Rate this:
Please Sign up or sign in to vote.
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.

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 :-))
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?
ProgramFOX 31-Oct-12 13:41pm
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 31 Oct 2012
Copyright © CodeProject, 1999-2017
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