Process.Start命令-查找正确的环境路径的问题 [英] Process.Start commands - Issues with finding proper environment paths

查看:122
本文介绍了Process.Start命令-查找正确的环境路径的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我们在使process.start命令在某些计算机上正常工作时遇到问题.我们要考虑32位或64位计算机.我们如何正确检查其中一个?这是到目前为止的代码.

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?

推荐答案

如果您拥有32位应用程序,则环境变量将是32位文件夹. 32位Program Files文件夹.如果您拥有64位应用程序,则环境变量将是64位Program Files文件夹.如果您有64位应用程序,但是如果要获取32位Program Files文件夹,请使用以下命令:
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)")



因此,环境变量的值不取决于计算机,而是取决于应用程序的类型(当然,您不能在32位计算机上运行64位应用程序:-))



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 :-))


这篇关于Process.Start命令-查找正确的环境路径的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆