帮忙看看,我用了下面这个函数,为什么还是不行?<br> 补充一下,我的目的是想等程序 B 退出后程序 A 才能操作。请再指教,不胜感激!function WinExec32(FileName: String; Wind_State: integer; Wait_Flag:<br> Boolean): integer;<br>var<br> AppName: array[0..512] of char;<br> CurDir: array[0..255] of char;<br> WorkDir: String;<br> StartupInfo: TStartupInfo;<br> ProcessInfo: TProcessInformation;<br>begin<br> StrPCopy(AppName, FileName);<br> GetDir(0, WorkDir);<br> StrPCopy(CurDir, WorkDir);<br> FillChar(StartupInfo, Sizeof(StartupInfo), #0);<br> StartupInfo.cb := Sizeof(StartupInfo);<br> StartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br> StartupInfo.wShowWindow := Wind_State;<br> {Case Wind_State of<br> 0: 窗口隐藏<br> 1: 窗口正常显示<br> 2: 窗口最小化显示,焦点在工具栏处的窗口TITLE上<br> 3: 窗口最大化显示<br> 4: 窗口正常显示,但无焦点<br> 5: 窗口正常显示,但有焦点<br> 6: 窗口最小化显示,焦点不在工具栏处的窗口TITLE<br> ......................<br> ....................<br> 参照 windows.pas<br> SW_HIDE = 0;<br> SW_SHOWNORMAL = 1;<br> SW_NORMAL = 1;<br> SW_SHOWMINIMIZED = 2;<br> SW_SHOWMAXIMIZED = 3;<br> SW_MAXIMIZE = 3;<br> SW_SHOWNOACTIVATE = 4;<br> SW_SHOW = 5;<br> SW_MINIMIZE = 6;<br> SW_SHOWMINNOACTIVE = 7;<br> SW_SHOWNA = 8;<br> SW_RESTORE = 9;<br> SW_SHOWDEFAULT = 10;<br> SW_MAX = 10;}<br><br> if not CreateProcess(nil,<br> AppName, { 命令行字符串 }<br> nil, { pointer to process security attributes }<br> nil, { pointer to thread security attributes }<br> false, { handle inheritance flag }<br> CREATE_NEW_CONSOLE or { creation flags }<br> NORMAL_PRIORITY_CLASS,<br> nil, { pointer to new environment block }<br> nil, { pointer to current directory name }<br> StartupInfo, { pointer to STARTUPINFO }<br> ProcessInfo) then<br> Result := -1 { pointer to PROCESS_INF }<br> else<br> begin<br> if Wait_Flag then<br> WaitforSingleObject(ProcessInfo.hProcess, INFINITE);<br> // if GetExitCodeProcess(ProcessInfo.hProcess,Result) then showmessage('调用成功完成')<br> // else showmessage('调用发生错误');<br> end;<br>end;<br><br>//调用<br>WinExec32('test.exe', 1, true);