如何从另一个exe调用1

如何从另一个exe调用1

本文介绍了如何从另一个exe调用1 exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

i有2个exe的

exe1:checklist.exe

exe2:reboot.exe



都是用C ++代码编写的。

现在我的exe1检查所有标准,如活动用户,进程,服务,如果每件事都按照要求罚款那么它必须重新启动我的exe2所做的系统。





现在我面临的问题是如何将两个exe链接在一起。更确切地说我想从exe1调用exe2。

所以如何在checklist.exe中编码调用reboot.exe





这里是我尝试的代码,但似乎效果不佳。

hi guys,
i have 2 exe's
exe1:checklist.exe
exe2:reboot.exe

both are written in C++ code.
now my exe1 check all the criteria like active users, processes,services and if every thing is fine as per requirement then it must reboot the system which my exe2 does.


now the problem i am facing is that how to i link both exe together. to be more precise i want to call exe2 from exe1.
so how do i code in checklist.exe which will call reboot.exe


here is the code i tried but seems not working well.

STARTUPINFO si = { sizeof(STARTUPINFO) };
	si.cb = sizeof(si);
	si.dwFlags = STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_HIDE;
	PROCESS_INFORMATION pi;
	CreateProcess("D:\\Autorbtchklst\\Release\\reboot.exe", NULL, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);







imp note:

我的exe2即reboot.exe也执行




imp note:
my exe2 i.e reboot.exe also accept 1 parameter while executing

推荐答案

引用:

但接受1参数但似乎效果不佳。

but seems not working well.

这不是很有用。





如果你需要将参数传递给创建的进程,那么正确构建 lpCommandLine CreateProcess 的参数。您可以在文档中找到示例代码: []。

That's not pretty informative.


If you need to pass arguments to the created process then properly build the lpCommandLine argument of CreateProcess. You may find sample code in the very documentation: CreateProcess at MSDN[^].



use WinExec


这篇关于如何从另一个exe调用1 exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:12