如何监视IE地址栏的内容(100分)

  • 主题发起人 主题发起人 darksmile
  • 开始时间 开始时间
D

darksmile

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp;我编了一个程序,需要获取IE地址栏的内容,而且必须动态刷新,<br>即用户试图打开一个新的网页时立即获取该网页的网址。我知道使用GetWindowText<br>函数,但无法确切知道什么时候用户才输入完整的网址。
 
写一个COM server,处理IE的消息,具体情检索webbrowser,或者参见 www.euromind.com/iedelphi
 
给你一个函数:<br><br>function URLInfo(sBrowerPrgFile, sServiceName: string; Netscape: boolean; var Title: string): pChar;<br>{<br>参数说明:<br>&nbsp; sBrowerPrgFile: 浏览器exe文件的完整路径名<br>&nbsp; sServiceName: &nbsp; 浏览器的DDE-Service名字<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Netscape是'Netscape',IE是'iexplore'<br>&nbsp; Title: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;返回当前网页的title<br>&nbsp; 返回值: &nbsp; &nbsp; &nbsp; &nbsp; pChar的字符串<br>}<br>var<br>&nbsp;DDEClientConv: TDDEClientConv;<br>&nbsp;StartPtr, EndPtr: pchar;<br>&nbsp; browserWinName: string;<br>begin<br>&nbsp;result:= #0;<br>&nbsp; Title:= '';<br><br>&nbsp; if (sBrowerPrgFile = '') or (not FileExists(sBrowerPrgFile)) then<br>&nbsp; raise EBrowserNotFoundError.create('****!浏览器应用程序不存在!');<br><br>&nbsp;ddeClientConv:= TDDEClientConv.Create( nil );<br>&nbsp; try<br>&nbsp; &nbsp; with ddeClientConv do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp;ServiceApplication := sBrowerPrgFile;<br>&nbsp; &nbsp; &nbsp; SetLink( sServiceName,'WWW_GetWindowInfo');<br>&nbsp; &nbsp; &nbsp; StartPtr:= RequestData('0xFFFFFFFF');<br>&nbsp; &nbsp; end;<br>&nbsp; finally<br>&nbsp; &nbsp;ddeClientConv.Free;<br>&nbsp; end;<br><br>&nbsp; if startPtr^ = #0 then<br>&nbsp; &nbsp;exit;<br>&nbsp; &nbsp; {skip leading "}<br>&nbsp; &nbsp; inc(StartPtr);<br>&nbsp; &nbsp; EndPtr:= StartPtr;<br>&nbsp; &nbsp; {proceed to next "}<br>&nbsp; &nbsp; while (EndPtr^ &lt;&gt; '"') do<br>&nbsp; &nbsp; &nbsp; inc(EndPtr);<br>&nbsp; &nbsp; {terminate URL string}<br>&nbsp; &nbsp; EndPtr^:= #0;<br>&nbsp; &nbsp; result:= StartPtr;<br>&nbsp; &nbsp; {skip ","}<br>&nbsp; &nbsp; StartPtr:= EndPtr+3;<br>&nbsp; &nbsp; if Netscape then<br>&nbsp; &nbsp; &nbsp; inc(StartPtr,12);<br><br>&nbsp; &nbsp; EndPtr:= StartPtr;<br>&nbsp; &nbsp; if Netscape then<br>&nbsp; &nbsp; &nbsp; while (EndPtr^ &lt;&gt; ']') do<br>&nbsp; &nbsp; &nbsp; &nbsp; inc(EndPtr)<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; while (EndPtr^ &lt;&gt; '"') do<br>&nbsp; &nbsp; &nbsp; &nbsp; inc(EndPtr);<br><br>&nbsp; &nbsp; EndPtr^:= #0;<br>&nbsp; &nbsp; Title:= strPas(StartPtr);<br>end;<br>
 
多人接受答案了。
 
后退
顶部