如何运行外部程序并连续传递变量? [英] How to run a external program and continuous passing variables to it?

查看:98
本文介绍了如何运行外部程序并连续传递变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个Win32应用程序,它们都是由VC +开发的。


第一个是被调用的程序,并带有循环结构。它允许连续接收字符串并执行某些操作,直到收到的字符串为"EXIT"。


第二个是调用程序,它将通过CreateProcess()执行第一个程序。我希望它可以保持进程,并让用户连续键入字符串,如"RUN","EXIT",所有这些字符串可以传递给被调用的程序,
我将从被调用的方式获取响应程序,然后记录。 



我的问题是:


如何保持这个过程还活着,我可以随时控制它吗?

解决方案

这样做的一般方法是:

 int wmain()
{
bool condition = true;
while(条件)
{
//在这里,某种方式将条件设置为false
}
返回0;
}

您可以对此使用一些变体,但这会使应用程序保持打开状态。显然,将条件设置为false的方法是当您收到字符串"EXIT"时。


此外,您可以随时控制它。


I had two Win32 applications, both are developed by VC+.

The first one is the called program, and with a loop structure. It allow continuous receiving string and do something until the received string is "EXIT".

The second one is the caller program, it will execute the fist program by CreateProcess(). I want it can hold the process, and let user continuous key-in string like "RUN", "EXIT", all of these string may pass to the called program, and I will fetch the response from called program, then record it. 

My question is:

How to keep the process alive, and I could control it anytime I want?

解决方案

The general way to do this is:

int wmain()
{
	bool condition = true;
	while (condition)
	{
		//in here, some way to set condition to false
	}
	return 0;
}

You can use some variation on this, but this keeps the application open. Obviously, the way to set the condition to false would be when you receive the string "EXIT".

Also, you can control it anytime you want.


这篇关于如何运行外部程序并连续传递变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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