How can I get the URL when Internet Explorer is Running?(200分)

  • 主题发起人 主题发起人 chenkai
  • 开始时间 开始时间
C

chenkai

Unregistered / Unconfirmed
GUEST, unregistred user!
我想设计一个后台运行的DELPHI程序,目的是获取Internet Explorer运行过程中所有在地址栏(URL)中输入或出现的信息,以便能知道到过何处访问。
 
全在这里:
C:/WINDOWS/History
 
监视
HKEY_CURRENT_USER/Software/Microsoft/Internet Explorer/TypedURLs
 
TypedURLs只是你"键入过"的URL, 通过link访问的无效.
 
>所有在地址栏(URL)中输入或出现的信息,
是我理解错了吗?
 
是的,我错了。
 
http://www.euromind.com/iedelphi/UrlHistory.htm
 
yysun,我连不上,能否好事做到底,把内容贴在这里?
 
我也想知道完整的答案
 
http://www.euromind.com/iedelphi/UrlHistory.htm
我怎吗联不上?
那位能贴出来
 
URLHIST Interfaces


StatUrl
STATURL = record
cbSize: DWORD;
pwcsUrl: DWORD;
pwcsTitle: DWORD;
ftLastVisited: FILETIME;
ftLastUpdated: FILETIME;
ftExpires: FILETIME;
dwFlags: DWORD;
end;



Staturl contains information about the enumerated entry in Urlhistory.

pwcsUrl : Pointer to a 0-terminated string containing the url.

pwcsTitel : Pointer to a 0-terminated string containing the titel.

ftLastVisited : Date/time the page was last visited. Even if it only was read from cache.

ftLastUpdated: Date/time the page was last actually read.

ftExpires: Date/time the page will be deletes from urlhistory.

CbSize, dwFlags: Unknown



To convert url and title to strings, you can use


Title:=PWidechar(Pointer(r.pwcsTitle));



To convert FILETIME to TDateTime:
var
l: Integer;
lft: TFileTime;
begin
FileTimeToLocalFiletime(Ft, lft);
FileTimeToDosDateTime(lft, Longrec(l).Hi, Longrec(l).Lo);
result := FiledateToDatetime(l);
end;




IEnumStatUrl


IEnumSTATURL = interface(IUnknown)
['{3C374A42-BAE4-11CF-BF7D-00AA006946EE}']
function Next(celt: Integer; out rgelt; var pceltFetched: PLongint): HResult; stdcall;
function Skip(celt: Integer): HResult; stdcall;
function Reset: HResult; stdcall;
function Clone(out ppenum: IEnumSTATURL): HResult; stdcall;
function SetFilter(poszFilter: PWideChar; dwFlags: Integer): HResult; stdcall;
end;



Clone:

Creates a duplicate enumerator containing the same enumeration state as the current one.

Returns S_OK if successful, or E_POINTER if ppEnum is an invalid pointer.

ppEnum duplicate of the enumerator.



Next:

Retrieves the specified number of staturl records in the enumeration sequence.

Returns one of the following values:S_OK Successful.
E_POINTER The rgelt pointer is invalid.
S_FALSE There are no more StatUrl to retrieve.



celt
Number of staturl records to place in the rgelt array.
rgelt
Array in which to place staturl records.
pcFetched
Actual number of staturl records placed in the array.


Reset:

Resets the enumeration sequence to the beginning.

Returns S_OK if successful.

This method affects the return value of the next call to the IEnumStatUrl.Next method.



Skip:

Skips a specified number of Call objects in the enumeration sequence.

Returns one of the following values:S_OK Success.
E_INVALIDARG celt is zero.
S_FALSE The celt value exceeds the number of Staturl records remaining in the enumeration.



celt
Number of UrlHistory entries to skip.
This method affects the return value of the next call to the IEnumStatUrl.Next method.



SetFilter:

????

Define filter for enumeration. Not really sure how to use this function, but:

SetFilter('http://',0) retrieves only entries starting with 'http.//'.


IUrlHistoryStg
IUrlHistoryStg = interface(IUnknown)
['{3C374A41-BAE4-11CF-BF7D-00AA006946EE}']
function AddUrl(pocsUrl: PWideChar; pocsTitle: PWideChar; dwFlags: Integer): HResult; stdcall;
function DeleteUrl(pocsUrl: PWideChar; dwFlags: Integer): HResult; stdcall;
function QueryUrl(pocsUrl: PWideChar; dwFlags: Integer; var lpSTATURL: STATURL): HResult; stdcall;
function BindToObject(pocsUrl: PWideChar; var riid: TIID; out ppvOut: Pointer): HResult; stdcall;
function EnumUrls(out ppenum: IEnumSTATURL): HResult; stdcall;
end;




AddUrl:

Add url to the history folder. IE/Webbrowser call this function when a document is loaded.

Ex:

AddUrl(PWideChar('http://www.microsoft.com'), PWidechar('Microsoft Corporation',0);

Flags: ???



DeleteUrl:

Delete a url from the history folder.

DeleteUrl(PWideChar('http://www.microsoft.com'),0);

Flags: ???



QueryUrl:

QueryUrl is called whenever the IE/Webbrowser wants to know if a links has been visited before. That means a call for every link on a page about to be displayed, so the color of link (visited/not visited) can be determined.

Return S_OK if the url is in history folder.

Flags: ???



EnumUrls:

Returns an instance of IEnumStatUrl:

I := CreateComObject(ClsId_CUrlHistory) as IUrlHistoryStg2;
I.EnumUrls(Enum);
Enum.SetFilter('http://', 0);
while enum.next(1, r, X) = S_OK do begin
Inc(Row);
StringGrid1.RowCount := Row + 1;
Stringgrid1.Cells[0, Row] := DateTimeToStr(FileTimeToDt(r.ftLastVisited));
Stringgrid1.Cells[1, Row] := PWidechar(Pointer(r.pwcsTitle));
Stringgrid1.Cells[2, Row] := PWidechar(Pointer(r.pwcsUrl));
Stringgrid1.Cells[3, Row] := DateTimeToStr(FileTimeToDt(r.ftLastUpdated));
Stringgrid1.Cells[4, Row] := DateTimeToStr(FileTimeToDt(r.ftExpires));
end;





IUrlHistoryStg2

IUrlHistoryStg2 = interface(IUrlHistoryStg)
['{AFA0DC11-C313-11D0-831A-00C04FD5AE38}']
function AddUrlAndNotify(pocsUrl: PWideChar; pocsTitle: PWideChar; dwFlags: Integer;
fWriteHistory: Integer; var poctNotify: Pointer;
const punkISFolder: IUnknown): HResult; stdcall;
function ClearHistory: HResult; stdcall;
end;






AddUrlAndNotify:

???



ClearHistory:

Deletes all entries in history.







The webbrowser makes a QueryInterface on IOleClientSite to get the IServiceProvider Interface. The IServiceProvider is an interface that gives you a way to obtain other interfaces that are related to the objet but not directly. Then webbrowser call IServiceProvider.QueryService(SID_STopLevelBrowser, IID_IUrlHistoryStg, UrlHist) to get IUrlHistoryStg interface.

 
接受答案了.
 

Similar threads

D
回复
0
查看
867
DelphiTeacher的专栏
D
D
回复
0
查看
785
DelphiTeacher的专栏
D
D
回复
0
查看
836
DelphiTeacher的专栏
D
后退
顶部