/ Published in: Delphi

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
procedure ExecNewProcess(ProgramName : String; Wait: Boolean); var StartInfo : TStartupInfo; ProcInfo : TProcessInformation; CreateOK : Boolean; begin { fill with known state } FillChar(StartInfo,SizeOf(TStartupInfo),#0); FillChar(ProcInfo,SizeOf(TProcessInformation),#0); StartInfo.cb := SizeOf(TStartupInfo); CreateOK := CreateProcess(nil, PChar(ProgramName), nil, nil,False, CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS, nil, nil, StartInfo, ProcInfo); { check to see if successful } if CreateOK then begin //may or may not be needed. Usually wait for child processes if Wait then WaitForSingleObject(ProcInfo.hProcess, INFINITE); end else begin ShowMessage('Unable to run '+ProgramName); end; CloseHandle(ProcInfo.hProcess); CloseHandle(ProcInfo.hThread); end;
URL: http://www.delphicorner.f9.co.uk/articles/wapi4.htm
Comments
