一、先定义几个外部变量
var
myhandle:THandle;
mystartupinfo:TStartupInfo;
myprocessinfo:TProcessInformation;
二、定义两个过程:
procedure execueapp(mypath:string);
procedure closeapp(myhandle:THandle);
实现:
procedure execueapp(mypath:string);
begin
FillChar(mystartupinfo,SizeOf(mystartupinfo),0);
//清除mystartupinfo中的数据
mystartupinfo.cb:= SizeOf(mystartupinfo);
CreateProcess(PChar(mypath),nil,nil,nil,False,DETACHED_PROCESS,nil,nil,mystartupinfo,myprocessinfo);
myhandle:=myprocessinfo.hProcess;
end;
procedure closeapp(myhandle:THandle);
begin
TerminateProcess(myhandle,0);
end;
三、在需要的位置调用者两个函数即可。