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;