该URL如:http://www.xxx.com/getvalue.asp?id=xxx需要向它发送一个请求,然后取得返回值。
在VB中是这样实现的
private sub btn_click()
  set inet=createobject("inetctls.inet")
  inet.url="http://www.xxx.com/getvalue.asp?id=xxx"
  inet.accesstype=0
  inet.requesttimeout=100
  text1.text=inet.openurl()
  set inet=noting
end sub如果是用xmlhttp,那么该如何声明,是否需要单独安装?我要做一个绿色软件。

解决方案 »

  1.   

    用indy控件中的inhttp,
    如:
    http://www.enet.com.cn/eschool/inforcenter/A20040429306316.html
      var 
       DownLoadFile:TFileStream; 
      beginio 
       DownLoadFile:=TFileStream.Create('c:\aa.rar',fmCreate); 
       IdHTTP1.Get('http://www.sina.com.cn/download/aa.rar',DownLoadFile); 
       DownLoadFile.Free; 
      end; 
      

  2.   

    invoke a HTTP Post request?  
      
    uses IdMultipartFormData; { .... } procedure TForm1.Button1Click(Sender: TObject); 
    var 
      data: TIdMultiPartFormDataStream; 
    begin 
      data := TIdMultiPartFormDataStream.Create; 
      try 
        { add the used parameters for the script } 
        data.AddFormField('param1', 'value1'); 
        data.AddFormField('param2', 'value2'); 
        data.AddFormField('param3', 'value3');     { Call the Post method of TIdHTTP and read the result into TMemo } 
        Memo1.Lines.Text := IdHTTP1.Post('http://localhost/script.php', data); 
      finally 
        data.Free; 
      end; 
    end;