T
TanXin
Unregistered / Unconfirmed
GUEST, unregistred user!
var
x,i: integer;
str:WideString;
ISW: IShellWindows;
spDisp: IDispatch;
IWB: IWebbrowser2;
IDoc:IHTMLDocument2 ;
InputText:IHTMLInputTextElement;
IEle:IHTMLElement;
begin
ISW := CoShellWindows.Create;
for x := 0 to ISW.Count - 1 do
begin
Memo1.Lines.Add((ISW.Item(x) as IWebbrowser2).LocationUrl);
Memo1.Lines.Add('...............................................................');
spDisp := ISW.Item(x);
spDisp.QueryInterface( IWebbrowser2,IWB);
if IWB<> nil then
begin
IWB.Document.QueryInterface(IHTMLDocument2,iDoc);
if (iDoc <> nil) then
begin
if((iDoc.charset<>'utf-8')and(IDoc.charset<>'gb2312'))then
begin
IWb.Quit();
ShowMessage('&micro;±&Ccedil;°&Iuml;&micro;&Iacute;&sup3;&frac12;&ucirc;&Ouml;&sup1;&auml;&macr;&Agrave;&Agrave;&Iacute;&acirc;&sup1;ú&Iacute;&oslash;&Otilde;&frac34;');
end;
end;
end;
end;
end;
我用这段代码来获取一个网站中的charset字段(网页的编码方式),但是却有的正确,有的不正确,请这是什么原因?
x,i: integer;
str:WideString;
ISW: IShellWindows;
spDisp: IDispatch;
IWB: IWebbrowser2;
IDoc:IHTMLDocument2 ;
InputText:IHTMLInputTextElement;
IEle:IHTMLElement;
begin
ISW := CoShellWindows.Create;
for x := 0 to ISW.Count - 1 do
begin
Memo1.Lines.Add((ISW.Item(x) as IWebbrowser2).LocationUrl);
Memo1.Lines.Add('...............................................................');
spDisp := ISW.Item(x);
spDisp.QueryInterface( IWebbrowser2,IWB);
if IWB<> nil then
begin
IWB.Document.QueryInterface(IHTMLDocument2,iDoc);
if (iDoc <> nil) then
begin
if((iDoc.charset<>'utf-8')and(IDoc.charset<>'gb2312'))then
begin
IWb.Quit();
ShowMessage('&micro;±&Ccedil;°&Iuml;&micro;&Iacute;&sup3;&frac12;&ucirc;&Ouml;&sup1;&auml;&macr;&Agrave;&Agrave;&Iacute;&acirc;&sup1;ú&Iacute;&oslash;&Otilde;&frac34;');
end;
end;
end;
end;
end;
我用这段代码来获取一个网站中的charset字段(网页的编码方式),但是却有的正确,有的不正确,请这是什么原因?