获取已经在IE中打开的网页的源代码 一个网页已经在IE中打开了,可以通过IE的菜单查看源代码。重新用这个网址去获取源代码的话,由于网站的限制,会重新出现登录的画面。所以要求不能再用那个网址去Get源代码。有个GetIESource的软件可以实现这个功能,但是想在自已的程序中查看这个网页的源代码。请问在DELPHI中怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function GetHtml(const WebBrowser:TWebBrowser): string;const BufSize = $10000;var Size: Int64; Stream: IStream; hHTMLText: HGLOBAL; psi: IPersistStreamInit;begin if not Assigned(WebBrowser.Document) then Exit; OleCheck(WebBrowser.Document.QueryInterface(IPersistStreamInit, psi)); try hHTMLText := GlobalAlloc(GPTR, BufSize); if 0 = hHTMLText then Exit;// RaiseLastWin32Error; OleCheck(CreateStreamOnHGlobal(hHTMLText, True, Stream)); try OleCheck(psi.Save(Stream, False)); Size := StrLen(PChar(hHTMLText)); SetLength(Result, Size); CopyMemory(PChar(Result), Pointer(hHTMLText), Size); finally Stream := nil; end; finally psi := nil; end;end; 给你一个例子吧下载这个http://eshow.ys168.com/infile/note/note_6.htm?http://ys-C.ys168.com/?WebBrowser.rar_67z80bt1bsp0c1bt0btl2bt0btlnnl0bp0cl2bikshu14z97f14z 一个局部变量简单问题 socket recv 用动态数组 怎么取数据?[救命] 有哪位大哥幫幫忙? 如何从TWebBrowser返回的网页中截取其中的一段 关于窗体的ShowModal和Show的问题. 媒体播放组件无法播放wmv之类的下文件类型提示mci错误如何解决 delphi 7 的应用程序在什么os下能用! 绝对送分 --- 微软 mfc ,pb pfc 我们在delphi上也扩充一下 delphi实现结构化存储 关于AnimateWindow的用法。 Pchar类型的转换 多数据库操作问题?在线等。。。。
function GetHtml(const WebBrowser:TWebBrowser): string;
const
BufSize = $10000;
var
Size: Int64;
Stream: IStream;
hHTMLText: HGLOBAL;
psi: IPersistStreamInit;
begin
if not Assigned(WebBrowser.Document) then Exit;
OleCheck(WebBrowser.Document.QueryInterface(IPersistStreamInit, psi));
try
hHTMLText := GlobalAlloc(GPTR, BufSize);
if 0 = hHTMLText then Exit;// RaiseLastWin32Error;
OleCheck(CreateStreamOnHGlobal(hHTMLText, True, Stream));
try
OleCheck(psi.Save(Stream, False));
Size := StrLen(PChar(hHTMLText));
SetLength(Result, Size);
CopyMemory(PChar(Result), Pointer(hHTMLText), Size);
finally
Stream := nil;
end;
finally
psi := nil;
end;
end;
下载这个
http://eshow.ys168.com/infile/note/note_6.htm?http://ys-C.ys168.com/?WebBrowser.rar_67z80bt1bsp0c1bt0btl2bt0btlnnl0bp0cl2bikshu14z97f14z