我有这种情况正在改变其他应用程序的某些设置一个应用程序(它是通过双击运行(无需安装)一个简单的C#应用程序)。
更改设置后我需要重新启动其他应用程序,以便它反映了更改的设置。
那么做,我要杀死正在运行的进程,并重新启动的过程中,但问题是杀戮,我无法找到后工序。 (原因是系统不知道该EXE文件。)
有没有办法找出正在运行的进程或EXE的路径,如果它正在运行?
我不希望如果它正在运行获取路径,杀proccess并开始再次别的手动给路径,即....稍后我会处理
解决方案 使用System.Diagnostics程序; 变种过程= Process.GetCurrentProcess(); //或者你使用任何方法 字符串FULLPATH = process.MainModule.FileName; //完整路径有exe文件的路径。有一个接球这个API,如果你正在运行32位程序的code,你不能够访问64位应用程序的路径,所以你必须编译并运行应用程序你作为64位应用程序。 (项目属性 - >建设 - >目标平台 - > 64)
I am having a application that is changing some settings of other application (it is a simple C# application that run by double clicking (no setup required)).
After changing the settings I need to restart the other application so that it reflects the changed settings.
So to do, I have to kill the running process and start the process again, But the problem is after killing I am not able to find the process. (Reason is system do not know where the exe file is..)
Is there any way to find out the path of running process or exe, if it is running?
I do not want to give path manually, i.e. if it is running get the path, kill the proccess and start again else .... I will handle later
解决方案 using System.Diagnostics; var process = Process.GetCurrentProcess(); // Or whatever method you are using string fullPath = process.MainModule.FileName; //fullPath has the path to exe.There is one catch with this API, if you are running this code in 32 bit application, you'll not be able to access 64-bit application paths, so you'd have to compile and run you app as 64-bit application. (Project Properties -> Build -> Platform Target -> x64)
更多推荐
C#中:如何获得运行进程的完整路径?
发布评论