如何在Windows应用程序中校准另一个exe? [英] How to cal another exe in my windows apps?

查看:92
本文介绍了如何在Windows应用程序中校准另一个exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...

当我单击解决方案中的一个按钮时,我想运行另一个exe..

为此,我正在使用Process.Start()方法.
当我给出整个路径时,它将正常工作.
例如:Process.Start("F://Honey//Second.exe");

但是我没有给出如何执行或校准Second Exe的路径.

我尝试过

Hi...

I want to run another exe when i click a button in my solution..

For this i am using Process.Start() Method..
It will work fine when i gave entire path..
ex: Process.Start("F://Honey//Second.exe");

But I without giving the path how i can execute or cal the Second Exe..

I tried

Process.Start("Second.exe");
        process.Start(Application.StartupPath + "//second.exe");


两者都显示错误msg

请帮助我....


问候
Honey .....


Both shows an error msg

Plz help me....


Regards
Honey.....

推荐答案

在不指定路径的情况下启动进程将使用标准的Windows查找顺序,大致来说是当前目录,然后是系统文件夹然后是路径环境变量.请注意,第一个查找是当前目录,而不是程序集所在的目录,尽管这两件事通常是相同的.
Starting a process with no path specified will use the standard Windows look up order, which is roughly speaking the current directory and then system folders and then the path environment variable. Note that the first lookup is the current directory, not the directory the assembly is in, though those two things are often the same.


阅读此内容应用程序注册 [ 无论如何,为了在不通过路径的情况下找到您的应用,您需要通过将其添加到系统PATH环境变量或应用路径"注册表项中进行注册,如链接中所示.

如果将第二个EXE复制到与您要从中创建进程的应用程序相同的路径,则可以使用Process.Start(Application.StartupPath +"\\ Second.exe");
Read this Application Registration[^]

Without including the path Windows does not know where to find "second.exe". Also I recommend using "/" or "\\" as your path separator instead of "//" you could also prepend @ to the start of your path string like so: @"C:\Honey\second.exe".
Anyway in order for your app to be found without passing the path you will need to register it by either adding it to the system PATH environment variable or the App Paths registry key as show in the link.

If you copy the second EXE to the same path as the app you are creating the process from you would then be able to use Process.Start(Application.StartupPath + "\\Second.exe");


这里是示例...

http://msdn.microsoft.com/en-us/library/system.diagnostics. process.aspx [^ ]
Here is the example...

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[^]


这篇关于如何在Windows应用程序中校准另一个exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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