delphi执行一个外部程序,当外部程序结束后,delphi程序立即响应
2009-10-27 20:48
330 查看
我们经常能看到360安全卫士进行windows系统升级时,执行windows升级程序,当升级程序执行完成后,360马上弹出提示框。
这样的程序是如何做到的呢?下述代码就能完成!
procedure TForm1.Button1Click(Sender: TObject);
var
SEInfo: TShellExecuteInfo;
ExitCode: DWORD;
ExecuteFile, ParamString, StartInString: string;
begin
ExecuteFile := 'c:/Windows/system32/Calc.exe';
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);
if ExitCode = STILL_ACTIVE then Sleep(500);
until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
ShowMessage('Calculator terminated');
end
else
ShowMessage('Error starting Calc!');
end;
这样的程序是如何做到的呢?下述代码就能完成!
procedure TForm1.Button1Click(Sender: TObject);
var
SEInfo: TShellExecuteInfo;
ExitCode: DWORD;
ExecuteFile, ParamString, StartInString: string;
begin
ExecuteFile := 'c:/Windows/system32/Calc.exe';
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);
if ExitCode = STILL_ACTIVE then Sleep(500);
until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
ShowMessage('Calculator terminated');
end
else
ShowMessage('Error starting Calc!');
end;
相关文章推荐
- delphi 执行一个外部程序,当外部程序结束后言主程序立即响应(新)
- delphi执行一个外部程序,当外部程序结束后,delphi程序立即响应
- delphi 执行一个外部程序,当外部程序结束后言主程序立即响应
- delphi执行一个外部程序,当外部程序结束后,delphi程序立即响应(续)
- delphi执行一个外部程序,当外部程序结束后,delphi程序立即响应
- delphi执行一个外部程序,当外部程序结束后,delphi程序立即响应
- delphi 执行一个外部程序,当外部程序结束后言主程序立即响应
- delphi 执行一个外部程序,当外部程序结束后言主程序立即响应
- delphi执行一个外部程序,当外部程序结束后,delphi程序立即响应
- delphi启动外部程序执行结束
- Delphi技巧集六 (等待执行完一个外部程序再执行另一个程序)
- Delphi 中实现判断某个外部程序是否运行(如果运行则执行一个命令否则执行一个命令)
- delphi启动外部程序并等待它执行结束-南山古桃(nsgtao) (转)-关键词:Delphi,外部程序,执行结束
- 执行一个外部程序并等待他的结束
- Delphi 调用外部程序并等待其运行结束
- Delphi调用一个外部程序时,如何把外部程序的窗体放在主程序窗体的Panel上?
- 用Delphi产生一个最小的可执行程序
- 如何让Delphi调用外部程序并等待其运行信息(如结束)
- delphi执行外部程序
- 调用外部程序并且等待结束后再继续执行程序