S
shipper123
Unregistered / Unconfirmed
GUEST, unregistred user!
调过一般的程序都没有问题。调用个别程序的时候就出现死机现象。源代码如下:
function ExecProcess(FileName:String;
Var hProcess,ProcessID:THandle):Boolean;
var
sInfo:TStartUpInfo;
pInfo:TProcessInformation;
begin
Result:=False;
FillChar(sInfo,sizeof(sInfo),#0);
with sInfodo
begin
cb:=sizeof(sInfo);
dwFlags:=STARTF_USESHOWWINDOW;
lptitle:=nil;
wShowWindow:=SW_SHOW;
end;
if CreateProcess(PChar(FileName),
nil,nil,nil,true,NORMAL_PRIORITY_CLASS,nil,nil,sInfo,pInfo) then
begin
hProcess:=pInfo.hProcess;
ProcessID:=pInfo.dwProcessId;
Result:=true;
end;
end;
procedure AddProcess(FileName:String;
hProcess,ProcessID:THandle);
Var
InfoProcessInfo;
begin
New(Info);
Info.hProcess:=hProcess;
Info.ProcessID:=ProcessID;
Info.Name:=ExtractFileName(FileName);
Info.Path:=ExtractFilePath(FileName);
List.Add(Info);
end;
//调用的过程(1) //大部分程序调用没有问题,但各别程序调用出现死锁现象(个别矢程序EXE本身是好的。)
if label8.Caption = 'xxxxx' then
begin
if Not ExecProcess('G:/user/xxxxx.exe',hProcess,ProcessID) then
Exit;
AddProcess('G:/user/xxxxx.exe',hProcess,ProcessID);
end;
//调用的过程(2) //所有的调用都没有问题,包括那个别程序调用的时候。
begin
if Not OpenDialog1.Execute then
Exit;
if Not ExecProcess(OpenDialog1.FileName,hProcess,ProcessID) then
Exit;
AddProcess(OpenDialog1.FileName,hProcess,ProcessID);
Memo1.Lines.Add(OpenDialog1.FileName);
function ExecProcess(FileName:String;
Var hProcess,ProcessID:THandle):Boolean;
var
sInfo:TStartUpInfo;
pInfo:TProcessInformation;
begin
Result:=False;
FillChar(sInfo,sizeof(sInfo),#0);
with sInfodo
begin
cb:=sizeof(sInfo);
dwFlags:=STARTF_USESHOWWINDOW;
lptitle:=nil;
wShowWindow:=SW_SHOW;
end;
if CreateProcess(PChar(FileName),
nil,nil,nil,true,NORMAL_PRIORITY_CLASS,nil,nil,sInfo,pInfo) then
begin
hProcess:=pInfo.hProcess;
ProcessID:=pInfo.dwProcessId;
Result:=true;
end;
end;
procedure AddProcess(FileName:String;
hProcess,ProcessID:THandle);
Var
InfoProcessInfo;
begin
New(Info);
Info.hProcess:=hProcess;
Info.ProcessID:=ProcessID;
Info.Name:=ExtractFileName(FileName);
Info.Path:=ExtractFilePath(FileName);
List.Add(Info);
end;
//调用的过程(1) //大部分程序调用没有问题,但各别程序调用出现死锁现象(个别矢程序EXE本身是好的。)
if label8.Caption = 'xxxxx' then
begin
if Not ExecProcess('G:/user/xxxxx.exe',hProcess,ProcessID) then
Exit;
AddProcess('G:/user/xxxxx.exe',hProcess,ProcessID);
end;
//调用的过程(2) //所有的调用都没有问题,包括那个别程序调用的时候。
begin
if Not OpenDialog1.Execute then
Exit;
if Not ExecProcess(OpenDialog1.FileName,hProcess,ProcessID) then
Exit;
AddProcess(OpenDialog1.FileName,hProcess,ProcessID);
Memo1.Lines.Add(OpenDialog1.FileName);