感覺上比gtk+裏的Spawning Processes好用,可以設定的東西也不少。

跟system()、exec()比起來,也不會比較差…

ShellExecute()  

小範例…

#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); //等到執行完

創作者介紹
創作者 鮪魚 的頭像
鮪魚

鮪魚

鮪魚 發表在 痞客邦 留言(0) 人氣( 274 )