用以下代码可以成功获取IE窗口选中区域的html代码,但到傲游浏览器中却不行,请赐教

eWong2016 2007-10-18 03:52:25
目的:从基于IE内核的傲游浏览器中取出选中区域的HTML代码
说明:在IE6下测试顺利通过,但在傲游浏览器中却在“错误1”处报错。

只有这些分了,真抱歉。

uses msHtml, SHdocvw;

procedure TForm2.Button1Click(Sender: TObject);
var
I: Integer;
ShellWindow: IShellWindows;
IE: IWebbrowser2;
Doc: IHtmlDocument2;
TxtRange: IHtmlTxtRange;
S: string;
P: PChar;
begin
ShellWindow := CoShellWindows.Create;
for I := 0 to ShellWindow.Count-1 do begin
IE := ShellWindow.Item(I) as IWebbrowser2;
if IE <> nil then begin
GetMem(P, MaxByte+1);
GetClassName(IE.HWND, P, MaxByte);// <<<-----“错误1
if SameText(P, 'IEFrame') then begin
Doc := IE.Document as IHtmlDocument2;
if Doc.Selection <> nil then begin
TxtRange := Doc.Selection.CreateRange as IHtmlTxtRange;
S := TxtRange.Get_htmlText;
Memo1.Lines.Add(S);
end;
end;
FreeMem(P);
end;
end;
end;
...全文
158 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
UltraBejing 2008-05-01
  • 打赏
  • 举报
回复
有点难度哦
knowledge_Is_Life 2008-05-01
  • 打赏
  • 举报
回复
接分是王道!
eWong2016 2007-11-04
  • 打赏
  • 举报
回复
有没有人能帮上我啊。。。。
eWong2016 2007-10-20
  • 打赏
  • 举报
回复
。。。
这个问题。。。。。。还真是。。。。个问题。。。。

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧