我循环调用ShellExecute(".exe",""),
for int i:=0 to 10 do
begin
ShellExecute(".exe","","");
End;因为我的exe文件里面会有运行Cmd的命令,所以每次ShellExecute就会有cmd的窗体弹出来,有什么办法等一个exe完全运行完毕再进行下一个ShellExecute的操作?
for int i:=0 to 10 do
begin
ShellExecute(".exe","","");
End;因为我的exe文件里面会有运行Cmd的命令,所以每次ShellExecute就会有cmd的窗体弹出来,有什么办法等一个exe完全运行完毕再进行下一个ShellExecute的操作?
begin
ShellExecute(0, 'Open', PChar('c:\sendmail.exe'), PChar('-fi ' + sTempFile), nil,SW_SHOWNORMAL);
End;sTempFile是我要用的参数。
因为我的exe文件里面会有运行Cmd的命令,所以每次ShellExecute就会有cmd的窗体弹出来,有什么办法等一个exe完全运行完毕再进行下一个ShellExecute的操作?
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=104460
const AWaitTime: Integer; const AIsShow: Boolean): Boolean;
var
stinfo:TStartupInfo;
psinfo:TProcessInformation;
sap,sat:TSecurityAttributes;
begin
Result:=False;
stinfo.dwFlags:=STARTF_USESHOWWINDOW;
stinfo.cbReserved2:=0;
stinfo.lpReserved:=nil;
stinfo.lpReserved2:=nil;
stinfo.lpDesktop:=nil;
if not AIsShow then
stinfo.wShowWindow:=SW_HIDE
else
stinfo.wShowWindow:=SW_SHOWNORMAL;
stinfo.cb:=SizeOf(TStartupInfo); sap.lpSecurityDescriptor:=nil;
sap.bInheritHandle:=True;
sap.nLength:=SizeOf(TSecurityAttributes);
sat.lpSecurityDescriptor:=nil;
sat.bInheritHandle:=False;
sat.nLength:=SizeOf(TSecurityAttributes); if FileExists(AExecutedFileName) and
CreateProcess(PChar(AExecutedFileName),'',@sap,@sat,False,NORMAL_PRIORITY_CLASS,nil,PChar(ExtractFilePath(ExpandFileName(AExecutedFileName))),stinfo,psinfo) then
begin
CloseHandle(psinfo.hThread);
Result:=WaitForSingleObject(psinfo.hProcess,AWaitTime) = WAIT_OBJECT_0;
CloseHandle(psinfo.hProcess);
end
else begin
RaiseLastOSError;
end;
end;