S
starluck
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var
xml :variant;
begin
xml:= CreateOleObject('Microsoft.XMLHTTP');
xml.open ('get','http://www.163.com',false);
//xml.setRequestHeader('Content-Type','text/xml');
//xml.setRequestHeader('charset','GB2312');
xml.send();
if xml.readystate<>4 then
begin
ShowMessage('取 网站信息失败');
exit;
end;
showmessage(ByteToStr(xml.responsebody,'GB2312'));
end;
// 将BYPE转换为 GB2312 格式
function TForm1.ByteToStr(body:variant; CSet: string): string;
var
GB_Body : Variant;
begin
{ objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
}
GB_Body := CreateOLeOBject('adodb.stream');
GB_boDy.mode := 3;
GB_body.write( body);
GB_body.position:=0;
GB_Body.Type :=2;
GB_Body.charset:=Cset;
result := GB_body.readtext;
end;
在GB_BODY.wite (body) 时总时提示类型不正确。请各位指导指导,谢谢了。
var
xml :variant;
begin
xml:= CreateOleObject('Microsoft.XMLHTTP');
xml.open ('get','http://www.163.com',false);
//xml.setRequestHeader('Content-Type','text/xml');
//xml.setRequestHeader('charset','GB2312');
xml.send();
if xml.readystate<>4 then
begin
ShowMessage('取 网站信息失败');
exit;
end;
showmessage(ByteToStr(xml.responsebody,'GB2312'));
end;
// 将BYPE转换为 GB2312 格式
function TForm1.ByteToStr(body:variant; CSet: string): string;
var
GB_Body : Variant;
begin
{ objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
}
GB_Body := CreateOLeOBject('adodb.stream');
GB_boDy.mode := 3;
GB_body.write( body);
GB_body.position:=0;
GB_Body.Type :=2;
GB_Body.charset:=Cset;
result := GB_body.readtext;
end;
在GB_BODY.wite (body) 时总时提示类型不正确。请各位指导指导,谢谢了。