用shellexecute打开一个文件时遇到的烦心事(30分)

  • 主题发起人 主题发起人 jobsxy
  • 开始时间 开始时间
J

jobsxy

Unregistered / Unconfirmed
GUEST, unregistred user!
我不知道该如何才能表达清楚,反正我用shellexecute打开网页文件时,总是在一个流览器<br>里打开,能否不同的网页文件分别打开?
 
这样来:<br><br>uses ComObj,ShellAPI;<br><br>procedure OpenInternetExplorer(sURL : string);//sURL参数为你要浏览的网址<br>&nbsp;const<br>&nbsp; &nbsp;csOLEObjName = 'InternetExplorer.Application';<br>&nbsp;var<br>&nbsp; &nbsp;IE : Variant;<br>&nbsp; &nbsp;WinHandle : HWnd;<br>&nbsp;begin<br>&nbsp; &nbsp;if VarIsEmpty(IE) then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;IE := CreateOleObject(csOLEObjName);<br>&nbsp; &nbsp; &nbsp;IE.Visible := true;<br>&nbsp; &nbsp; &nbsp;IE.Navigate(sURL);<br>&nbsp; &nbsp;end<br>&nbsp; &nbsp;else<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;WinHandle := FindWindow('IEFrame', nil);<br>&nbsp; &nbsp; &nbsp;if WinHandle &lt;&gt; 0 then<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;IE.Navigate(sURL);<br>&nbsp; &nbsp; &nbsp; &nbsp;SetForegroundWindow(WinHandle);<br>&nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;// handle error ...<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp;end;<br>&nbsp;end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; OpenInternetExplorer('www.sina.com.cn');<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; OpenInternetExplorer('www.263.net');<br>end;
 
后退
顶部