if Assigned(p) then p(Application.Handle, PChar(FavFolder));
end;
FreeLibrary(h);
end;
procedure TForm1.AddFavorite(Sender: TObject);
var
ShellUIHelper: ISHellUIHelper;
url, title: Olevariant;
begin
Title := Webbrowser1.LocationName;
Url := Webbrowser1.LocationUrl;
if Url <> then
begin
ShellUIHelper := CreateComObject(CLSID_SHELLUIHELPER) as IShellUIHelper;
ShellUIHelper.AddFavorite(url, title);
end;
end;
4.直接从TWebBrowser得到网页源码及Html
Memo1.Lines.Add(IHtmlDocument2(WebBrowser1.Document).Body.OuterHtml);
如果,用TWebBrowser浏览HTML文件的时候要将其保存为文本文件就很简单了,
Memo1.Lines.Add(IHtmlDocument2(WebBrowser1.Document).Body.OuterText);
5.获取IE地址栏的handle
var
Form1: TForm1;
implementation
{$R *.DFM}
Function GetURL(H:hwnd;lparam:longint):boolean;stdcall;
var str,url:array [0..254] of char;
begin
getclassname(h,@str,255);
if strpas(@str)=ComboBoxEx32 then // ComboBoxEx32可以改成Edit.
begin
SendMessage(h,WM_GETTEXT,255,LongInt(@url));
SendMessage(h,WM_SETTEXT,255,longint(pchar(http://www.sina.com.cn)));
Sendmessage(h,WM_KEYDOWN,VK_Return,1);
form1.ListBox1.Items.Add(strpas(@url));
end;
result:=true;
end;
function callbackproc(H:HWnd;lparam:longint):Boolean;stdcall;
var str:array [1..255] of char;
begin
getclassname(h,@str,255);
if ((strpas(@str)=CabinetWClass) or (strpas(@str)=IEFrame)) then
begin
Enumchildwindows(h,@GetURL,0);
end;
result:=true;
end;
procedure TForm1.findbuttonClick(Sender: TObject);
begin
listbox1.Clear;
Enumwindows(@callbackproc,0);
end;
end.