-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProcessUtil.pas
42 lines (33 loc) · 993 Bytes
/
ProcessUtil.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
unit ProcessUtil;
interface
uses windows;
function CreateProcessSimple(cmd: string): boolean;
implementation
function CreateProcessSimple(cmd: string): boolean;
var
SUInfo: TStartupInfo;
ProcInfo: TProcessInformation;
begin
FillChar(SUInfo, SizeOf(SUInfo), #0);
SUInfo.cb := SizeOf(SUInfo);
SUInfo.dwFlags := STARTF_USESHOWWINDOW;
SUInfo.wShowWindow := SW_HIDE;
Result := CreateProcess(nil,
PChar(cmd),
nil,
nil,
false,
CREATE_NEW_CONSOLE or
NORMAL_PRIORITY_CLASS,
nil,
nil,
SUInfo,
ProcInfo);
if (Result) then
begin
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
end;
end;
end.