等待程序结束(80分)

  • 主题发起人 主题发起人 留香客
  • 开始时间 开始时间

留香客

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp; 我是这样写的<br>&nbsp; &nbsp; &nbsp; &nbsp;shellexecute(handle,nil,'c:/windows/notepad.exe',nil,nil,sw_normal);<br>&nbsp; &nbsp; &nbsp; &nbsp;findwindow(nil,'form1');<br>&nbsp; 但是得不到句柄,我知道是因为notepad还未初始化造成的,各位,问题就是,怎么知道<br>notpad已经完全打开了?
 
procedure TForm1.Button1Click(Sender: TObject);<br>var<br>HWndCalculator : HWnd;<br>begin<br>// find the exist window<br>HWndCalculator := FindWindow(nil, ''c:/windows/notepad.exe'); <br>if HWndCalculator &lt;&gt; 0 then<br>&nbsp; findwindow(nil,'form1');<br>end;<br>&nbsp;<br>&nbsp; &nbsp; &nbsp;
 
&nbsp;to cwmdelpher:<br>&nbsp; &nbsp; &nbsp;NO USE!!
 
shellexecute(handle,nil,'c:/windows/notepad.exe',nil,nil,sw_normal);<br>while (HWndCalculator = 0) then<br>begin<br>&nbsp; HWndCalculator := FindWindow(nil, ''c:/windows/notepad.exe'); <br>end ;<br>&nbsp; findwindow(nil,'form1');<br>
 
搞错没有?怎么能找不到呢,<br>是不是你的form1的caption不是form1啊???
 
FindWindow(类名,标题名)<br>返回值是句柄。<br><br>请问,你的记事本打开后的标题名是不是form1呢?
 
&nbsp; 谢谢各位,我没说清楚吧。是这样的<br>&nbsp; &nbsp;ok:=shellexecute(handle,nil,pchar('word.exe'),nil,nil,5);<br>&nbsp; &nbsp; &nbsp; &nbsp;if ok&lt;&gt;0 then<br>&nbsp; &nbsp; &nbsp; &nbsp;while (Mhandle=0) do<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MHandle:=findwindow(nil,pchar('标题名'));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;application.ProcessMessages;<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp;这样当被调用程序出错退出时,会造成调用程序死循环!并且被调用程序初始化<br>时间不定(初始化完成后显示标题,不能设循环次数)<br>&nbsp; &nbsp;各位,问题就是,怎么知道程序已经完全打开了?
 
多人接受答案了。
 

Similar threads

后退
顶部