执行一个外部程序并等待他的结束
//下面的函数执行一个程序并且等他的结束。
//在外部程序结束运行之前,不能做任何操作!
//EXL:WinExecW('C:\Windows\NOtePad.exe', '', sw_show);
Function WinExecW(CMD, WorkDir: PChar; Visialbe: integer):DWORD;
var
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
begin
FillChar(StartupInfo, Sizeof(StartupInfo), #0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visible;
if not CreaeProcess(nil, cmd, nil, nil, false, Create_new_console or
Normal_priority_class, nil, nil, StartupInfo, ProcessInfo) then
result := 0
else
begin
Waitforsingleobject(Processinfo.hProcess, INFINITE);
GetExicodeProcess(Processinfo.hProcess, Result);
end;