我在一段代码中采用ShellExecute调用一个外部程序,我希望调用进程等到这个外部进程退出后才继续执行,该如何操作呢。
例子:
MainPro:
A
B
ShellExcecute(outerProcess)
C
D
当主进程执行到ShellExcecute时,暂停直到outerProcess执行接收后才执行C、D,该如何操作呢
例子:
MainPro:
A
B
ShellExcecute(outerProcess)
C
D
当主进程执行到ShellExcecute时,暂停直到outerProcess执行接收后才执行C、D,该如何操作呢
解决方案 »
- 不能打印的问题!
- cxGrid 删除所有行的问题?
- TQRRichText 可以设置行间距了,为什么TQRDBRichText就不可以哦????
- 我来问个简单问题!DBGRID怎么排序呀?
- 哪有好点的能下载的源码网站?
- 用DELPHI 开发XML方面的有什么好书?
- 大家快来跟cobi小新解决一个难题,一个女孩子在追他,他不知道改不该接受呵呵,看到他这么痛苦,我就替他来这里问问,来者有分,提出高见者,高分相送
- 为何DBgrid只可显示小数点后的四位,不知如何显示更多位?
- 谁有这样的源代码???(在二进制文件中查找$DDEEFF)
- 有关程序图标的问题
- 大批量数据录入问题
- CrystalReport打印动态列如何实现?谢谢,请高手具体点。或者有没有现成的例子?
http://community.csdn.net/Expert/topic/3715/3715128.xml?temp=.6361048
// a message when the Calc is terminated.
uses ShellApi;
...
var
SEInfo: TShellExecuteInfo;
ExitCode: DWORD;
ExecuteFile, ParamString, StartInString: string;
begin
ExecuteFile:='c:\Windows\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);
until (ExitCode <> STILL_ACTIVE) or
Application.Terminated;
ShowMessage('Calculator terminated');
end
else ShowMessage('Error starting Calc!');
end;