用这个实现等程序运行结束后在执行下面的东东。
function WinExecAndWait32_v1(FileName: string
Visibility: integer):
Cardinal
{integer}
var
zAppName: array[0..512] of char
zCurDir: array[0..255] of char
WorkDir: string
StartupInfo: TStartupInfo
ProcessInfo: TProcessInformation
begin
StrPCopy(zAppName, FileName)
GetDir(0, WorkDir)
StrPCopy(zCurDir, WorkDir)
FillChar(StartupInfo, Sizeof(StartupInfo), #0)
StartupInfo.cb := Sizeof(StartupInfo)
StartupInfo.dwFlags := STARTF_USESHOWWINDOW
StartupInfo.wShowWindow := Visibility
if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
true, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name, PChar}
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) { pointer to PROCESS_INF }
then Result := INFINITE {-1} else
begin
WaitforSingleObject(ProcessInfo.hProcess, INFINITE)
GetExitCodeProcess(ProcessInfo.hProcess, Result)
CloseHandle(ProcessInfo.hProcess)
{ to prevent memory leaks }
CloseHandle(ProcessInfo.hThread)
end
end
如果你定时2分钟,就可以在另一个程序里加入一个timer,在onshow时把tiemr打开,
timer的时长定为120000,在ontimer里加入close;
OK了。