var<br> ThisHandle: THandle;<br> ThisStartupInfo: TStartupInfo;<br> ThisProcessInfo: TProcessInformation;<br>procedure TForm1.ExecuteApp(ThisPath: String);<br>begin<br> FillChar(ThisStartupInfo,SizeOf(ThisStartupInfo),0);<br>//清除ThisStartupInfo中的数据<br> ThisStartupInfo.cb:= SizeOf(ThisStartupInfo);<br> CreateProcess(PChar(ThisPath),nil,nil,nil,False,DETACHED_PROCESS,nil,nil,ThisStartupInfo,ThisProcessInfo);<br> //winexec(PChar('c:/peak/peak.exe'), SW_SHOWNORMAL);<br> ThisHandle := ThisProcessInfo.hProcess;<br> //把执行的程序句柄赋值给ThisHandle,它会终止程序时用到<br>end;<br><br>procedure TForm1.CloseApp(ThisHandle: THandle);<br>begin<br> TerminateProcess(ThisHandle,0);<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> m_hWnd :HWND;<br>begin<br> m_hWnd := FindWindow(nil,'peak');<br> if m_hWnd = 0 then ExecuteApp('C:/PEAK/Peak.exe');<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br> CloseApp(ThisHandle);<br>end;<br>=======================================<br>这样写后程序一个都不能打开~???请高手检查