X003Handle : THandle; ST : TStartupInfo; PT : TProcessInformation;procedure StartX003Exe; begin FillChar(ST, SizeOf(ST), #0); with ST do begin cb := Sizeof(ST); dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW; lpTitle := nil; wShowWindow := SW_SHOW; end;X003Handle := OpenProcess(PROCESS_ALL_ACCESS, False, PT.dwProcessId); TerminateProcess(X003Handle, 0); try if not CreateProcess(Pchar('X003Exe.exe'),nil,nil,nil,true, DETACHED_PROCESS, nil,nil,ST,PT) then begin MessageBox(Application.DialogHandle, PChar(ErrStartExe), PChar(MsgTitle), MB_OK + MB_ICONINFORMATION); Application.Terminate; end; except on e: exception do showMessage(e.Message); end; end;
贴乱了:变量不贴了,两个函数重新贴: procedure StartX003Exe; begin FillChar(ST, SizeOf(ST), #0); with ST do begin cb := Sizeof(ST); dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW; lpTitle := nil; wShowWindow := SW_SHOW; end; try if not CreateProcess(Pchar('X003Exe.exe'),nil,nil,nil,true, DETACHED_PROCESS, nil,nil,ST,PT) then begin MessageBox(Application.DialogHandle, PChar(ErrStartExe), PChar(MsgTitle), MB_OK + MB_ICONINFORMATION); Application.Terminate; end; except on e: exception do showMessage(e.Message); end; end;procedure KillX003Exe; begin X003Handle := OpenProcess(PROCESS_ALL_ACCESS, False, PT.dwProcessId); TerminateProcess(X003Handle, 0); end;
ST : TStartupInfo;
PT : TProcessInformation;procedure StartX003Exe;
begin
FillChar(ST, SizeOf(ST), #0);
with ST do
begin
cb := Sizeof(ST);
dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW;
lpTitle := nil;
wShowWindow := SW_SHOW;
end;X003Handle := OpenProcess(PROCESS_ALL_ACCESS, False, PT.dwProcessId);
TerminateProcess(X003Handle, 0);
try
if not CreateProcess(Pchar('X003Exe.exe'),nil,nil,nil,true, DETACHED_PROCESS, nil,nil,ST,PT) then
begin
MessageBox(Application.DialogHandle, PChar(ErrStartExe),
PChar(MsgTitle), MB_OK + MB_ICONINFORMATION);
Application.Terminate;
end;
except
on e: exception do
showMessage(e.Message);
end;
end;
procedure StartX003Exe;
begin
FillChar(ST, SizeOf(ST), #0);
with ST do
begin
cb := Sizeof(ST);
dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW;
lpTitle := nil;
wShowWindow := SW_SHOW;
end;
try
if not CreateProcess(Pchar('X003Exe.exe'),nil,nil,nil,true, DETACHED_PROCESS, nil,nil,ST,PT) then
begin
MessageBox(Application.DialogHandle, PChar(ErrStartExe),
PChar(MsgTitle), MB_OK + MB_ICONINFORMATION);
Application.Terminate;
end;
except
on e: exception do
showMessage(e.Message);
end;
end;procedure KillX003Exe;
begin
X003Handle := OpenProcess(PROCESS_ALL_ACCESS, False, PT.dwProcessId);
TerminateProcess(X003Handle, 0);
end;