function TDMDb.WaitExeFinish(const sCmdName: string):boolean;
var
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
b:boolean;
begin
// 初始化
FillChar(StartupInfo, SizeOf(StartupInfo), );
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := SW_HIDE; // 隐藏执行 // 执行命令行
b:=CreateProcess(nil, PWideChar(sCmdName), nil, nil, False, , nil, nil, StartupInfo, ProcessInfo); // 等待执行完成
with ProcessInfo do
begin
CloseHandle(hThread);
WaitForSingleObject(hProcess, INFINITE);
CloseHandle(hProcess);
end; // 返回
Result := b;
end;
http://blog.csdn.net/shuaihj/article/details/8890419