如何改变alredy运行过程的参数 [英] How to change argument of alredy running process

查看:163
本文介绍了如何改变alredy运行过程的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的PC上已经有一个进程(baretail.exe)。在同一个进程中我想打开另一个文本文件。基本上我想改变/设置过程的参数。有可能吗?任何评论都非常感谢。



谢谢

Hi all,

I have a process (baretail.exe) already running in my PC. On the same process I want to open another text file. Basically I want to change/set the argument of the process. Is it possible to do that? Any comments really appreciate.

Thanks

推荐答案

Nope。一个进程在启动时读取它的参数。

但是,如果你可以修改它,那么你可以使用某种 IPC [ ^ ]用于在运行时传递参数。
Nope. A process reads its arguments at startup.
However, if you can modify it, then you may use some sort of IPC[^] for passing it parameters at runtime.


如果处理该文本文件已更改,则可以执行此操作。在更改的文本文件事件中,您可以重新启动该过程以在文本文件中获取新参数。



Ex:

You can do that, if you handle that text file was changed. In the changed event of text file, you can restart that process to get new arguments in text file.

Ex:
private void Form1_Load(object sender, EventArgs e)
{
    FileSystemWatcher file = new FileSystemWatcher("C:\\Text.txt");
    file.Changed += new FileSystemEventHandler(file_Changed);
}

void file_Changed(object sender, FileSystemEventArgs e)
{
    //Restart your process here (stop and start)
}



注意:在读取执行进程的参数时,不要总是打开这个文本文件,因为这次会锁定文本文件,所以你无法编辑文本文件。

希望这个帮助


Note: Don''t always open this text file when reading arguments to execute process, because this time will lock text file, so you cannot edit text file.
Hope this help


如果没有ipc,如果你启动它,你会得到一个新的实例。但是,您可以通过模拟用户操作来尝试自动化它:向进程发送Windows消息。您可以使用AutoIT捕获事件并获取概述,或者像 WinSPY [ ^ ]和 Window Detective [ ^ ]看看是什么消息被发送。



但是直接用能够做你想做的事的c#替换那个应用程序可能更容易。
In case of baretail there is no ipc, and if you start it, you get a new instance. You could however try to automate it, by emulating user action: sending windows messages to the process. You can use AutoIT to capture events and get an overview, or something like WinSPY[^] and Window Detective[^] to see what messages are sent.

But it would be probably easier to make a replacement of that application directly in c# that is capable of doing what you want.


这篇关于如何改变alredy运行过程的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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