感覺上比gtk+裏的Spawning Processes好用,可以設定的東西也不少。
跟system()、exec()比起來,也不會比較差…
小範例…
#include <windows.h>
#include <shellapi.h>
...
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = "C:\\WINDOWS\\system32\\xcopy.exe";
ShExecInfo.lpParameters = cmd; //cmd 是字串
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
shell_exec_state = ShellExecuteEx(&ShExecInfo); //shell_exec_state為bool value
WaitForSingleObject(ShExecInfo.hProcess,INFINITE); //等到執行完
請先 登入 以發表留言。