Hola.
Tengo un programa que lee el código HTML de una página web y todos sus frames con el componente TWebBrowser. Hace tiempo funcionaba perfectamente, pero ahora lo vuelvo a probar y el código fuente de la página principal lo saca bien, pero cuando va a sacar el de los frames me da un error: EIntfCastError with message "Interface not supported".
Creo que debe ser por la versión de Internet Explorer que ahora tengo la 9 y cuando usaba este programa supongo que tendría la 6 o la 7, pero no estoy seguro si es por eso.
El progama es:
Código Delphi
[-]procedure TF_Principal.ObtenerHTML;
var
IpStream : IPersistStreamInit;
AStream : TMemoryStream;
iw : IWebbrowser2;
i : Integer;
sl : TStringList;
OleContainer : IOleContainer;
enum : IEnumUnknown;
unk : IUnknown;
Fetched : System.PLongint;
ss : TStringStream;
sa : IStream;
s : string;
HTML : String;
StreamA : TStreamadapter;
begin
if WB <> nil then
begin
WB.Silent := True;
IpStream := WB.Document as IPersistStreamInit;
s := '';
ss := TStringStream.Create(s);
try
sa := TStreamAdapter.Create(ss, soReference) as IStream;
if Succeeded(IpStream.Save(sa, True)) then
HTML := ss.Datastring
else
HTML := '';
finally
ss.Free;
end;
AnalizarHTML(HTML);
for i := 0 to WB.OleObject.Document.frames.Length - 1 do
begin
if Assigned(WB.document) then
begin
Fetched := nil;
OleContainer := WB.Document as IOleContainer;
OleContainer.EnumObjects(OLECONTF_EMBEDDINGS, Enum);
Enum.Skip(i);
Enum.Next(1, Unk, Fetched);
try
iw := Unk as IWebbrowser2; **** LINEA DONDE DA EL ERROR *****
except
end;
end;
AStream := TMemoryStream.Create;
IpStream := iw.document as IPersistStreamInit;
StreamA := TStreamadapter.Create(AStream);
if Succeeded(IpStream.save(StreamA, True)) then
begin
AStream.Seek(0, 0);
sl := TStringList.Create;
sl.LoadFromStream(AStream);
AnalizarHTML(sl.Text);
sl.Free;
end;
StreamA.Free;
AStream.Free;
end;
end;
end;
¿ Alguien sabe que puede estar pasando ?
Gracias.