procedure TMainFrm.btn_createprocessClick(Sender: TObject);
var
startupinfo:tstartupinfo;
processinfo:tprocessinformation;
begin
//初始化工作
fillchar(startupinfo,sizeof(startupinfo),#0);
startupinfo.cb:= sizeof(startupinfo);
startupinfo.dwFlags := startf_useshowwindow;
//执行文件并等待其结束
if createprocess(nil,pchar(edt_run.text),nil,nil,false,
create_new_console or normal_priority_class,nil,nil,startupinfo,processinfo) then
begin
WaitForSingleObject(ProcessInfo.hProcess,infinite);
// do something during ....
end;
//到此程序结束,可以在这里让另一个程序运行。。。
end;