TIdHTTP
头文件包含:
#include <IdHTTP.hpp>
#include <IdTCPClient.hpp>
#include <IdTCPConnection.hpp>
#include <IdHTTPServer.hpp>
#include <IdTCPServer.hpp>
库加载:
把C:\Program Files (x86)\Borland\CBuilder6\Lib\Release\indy.lib添加到项目里
例子
TIdHTTP *IdHttp=NULL;
try
{
TIdHTTP *IdHttp = new TIdHTTP(this); //´´½¨Ò»¸öTidHTTP¶ÔÏó
TStringStream *stream_Website = new TStringStream(""); //´´½¨WebsiteÁ÷¶ÔÏó
AnsiString string_Pagedata = ""; //Ò³ÃæData
IdHttp->Get("www.baidu.com",stream_Website); //»ñÈ¡Ò³Ãæ
string_Pagedata = stream_Website->DataString; //´ÓÁ÷Öб£´æÒ³ÃæÊý¾Ýµ½Ò»¸öString¶ÔÏóÖÐ
delete stream_Website; //ÊÍ·Å×ÊÔ´
delete IdHttp; //ÊÍ·Å×ÊÔ´
}
catch(Exception &e)
{
ShowMessage("error: "+e.Message);
if(IdHttp!=NULL)
delete IdHttp;
}
TCppWebBrowser
如果在Internet后面没有CppWebBrowser控件,则需要手动添加到环境中:
Component-->Install Packages-->安装到新组件包-->找到$(BCB)/bin/bcbie60.bpl添加进来(如果连这个文件也找不到,可能是你的BCB安装不太完整)-->如果列表中存在这一项,请选中对面的对钩,这样就OK了
例子
if (CppWebBrowser1->Busy)
CppWebBrowser1->Stop();
int len = cxHyperLinkEdit1->Text.WideCharBufSize();
wchar_t *buf=new wchar_t[len+1];
CppWebBrowser1->Navigate(cxHyperLinkEdit1->Text.WideChar(buf,len));
delete[] buf;