哎呀,差点忘了,在程序中加入对程序b(在我这儿是sub)的调用,以下是上面那个例<br>子的继续:<br>function WinExecProcess(FileName:String; Visibility : integer):boolean;<br>var<br> zAppName:array[0..512] of char;<br> zCurDir:array[0..255] of char;<br> WorkDir:String;<br> StartupInfo:TStartupInfo;<br> ProcessInfo:TProcessInformation;<br>begin<br> StrPCopy(zAppName,FileName);<br> GetDir(0,WorkDir);<br> StrPCopy(zCurDir,WorkDir);<br> FillChar(StartupInfo,Sizeof(StartupInfo),#0);<br> StartupInfo.cb := Sizeof(StartupInfo);<br> StartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br> StartupInfo.wShowWindow := Visibility;<br> if not CreateProcess(nil,<br> zAppName, { pointer to command line string }<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, { 继承当前程序的环境!}<br> nil, { pointer to current directory name }<br> StartupInfo, { pointer to STARTUPINFO }<br> ProcessInfo) then<br> Result := false { pointer to PROCESS_INF }<br> else<br> Result := true;<br> end;<br>}<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> cmdline :string;<br>begin<br> cmdline := ExtractFilePath(paramstr(0))+'sub.exe';<br> if not WinExecProcess(cmdline,1) then<br> showmessage('could not call program sub!');<br>end;<br>