problemer med at køre et program og vendte
Hej,Jeg fandt nedenstående kode på delphi about hjemmeside
http://delphi.about.com/od/windowsshellapi/a/executeprogram.htm
Problemet er at delphi bruger alt processer tid i det nederst loop uden at det eksterne program bliver afviklet. Det ser ud til application.processmessage ikke bliver udført.
ExecuteFile:='calc.exe';
ParamString:='paramters.txt';
FillChar(SEInfo, SizeOf(SEInfo), 0) ;
SEInfo.cbSize := SizeOf(TShellExecuteInfo) ;
with SEInfo do begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := Application.Handle;
lpFile := PChar(ExecuteFile) ;
{
ParamString can contain the
application parameters.
}
lpParameters := PChar(ParamString) ;
{
StartInString specifies the
name of the working directory.
If ommited, the current directory is used.
}
// lpDirectory := PChar(StartInString) ;
nShow := SW_SHOWNORMAL;
end;
if ShellExecuteEx(@SEInfo) then begin
repeat
Application.ProcessMessages;
GetExitCodeProcess(SEInfo.hProcess, ExitCode) ;
until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
// ShowMessage('Calculator terminated') ;
end
else ShowMessage('Error starting Calc!') ;
