我想知道如何在windows中打开任何应用程序使用c++编程,我正在使用开发的c++。我使用了system(),但它的性能不是很好,或者我没有正确使用它。请告诉我打开一个应用程序或告诉另一个函数的system()语法。
发布于 2013-06-27 16:39:20
使用shell执行而不是system for windows。
#include <Windows.h>
//Link with library: Shell32.lib or libshell32.a
ShellExecute(
NULL, //handle to the parent window
"open", //Action to take
"Notepad.exe", //Program path
"arg1 arg2", //Command line arguments
"C:\\", //Start in what directory
SW_SHOWMAXIMIZED //Window state
);至于system(),它只需要一个参数,这个参数与您在控制台( cmd.exe )中输入的参数相同。例如,system("dir /a");的作用与在cmd.exe中输入dir /a完全相同
如果在devC++中构建时遇到问题,请检查项目属性。
从“项目选项”>“目录”>
\MinGW64\x86_64-w64-mingw32\lib32\MinGW64\x86_64-w64-mingw32\include从‘项目选项’>参数>链接器
-lshell32发布于 2013-06-27 16:37:56
你试过CreateProcess吗?
CreateProcess(lpApplicationName
NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
lpStartupInfo,
lpProcessInformation
)https://stackoverflow.com/questions/17338409
复制相似问题