procedure TForm1.Button1Click(Sender: TObject);
var
sCommandLine:string;
bCreateProcess: boolean;
lpStartupInfo: TStartupInfo;
lpProcessInformation: TProcessInformation;
begin
sCommandLine :='C:\TEST.EXE';
//初始化StartupInfo
FillChar(lpStartupInfo, Sizeof(TStartupInfo), #0);
lpStartupInfo.cb := Sizeof(TStartupInfo);
lpStartupInfo.dwFlags := STARTF_USESHOWWINDOW;
lpStartupInfo.wShowWindow := SW_NORMAL;
bCreateProcess := CreateProcess(nil, PChar(sCommandLine),
nil,nil, True, CREATE_NEW_CONSOLEor NORMAL_PRIORITY_CLASS,
nil,nil, lpStartupInfo, lpProcessInformation);
if bCreateProcessthen//等外部进程的结束
WaitForSingleObject(lpProcessInformation.hProcess, INFINITE);
end;