64,637
社区成员
发帖
与我相关
我的任务
分享
#include <afxinet.h>
CString& getIP(){
CInternetSession mySession;
CHttpFile* myHttpFile=NULL;
CString IP;
myHttpFile=(CHttpFile*)mySession.OpenURL(url,1,INTERNET_FLAG_DONT_CACHE,NULL,0);
myHttpFile->ReadString(IP);
myHttpFile->Close();
delete []myHttpFile;
mySession.Close();
return IP;
}
CInternetSession mySession;
CHttpFile* myHttpFile=NULL;
CString myData;
CString IP;
mySession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,1000);
myHttpFile=(CHttpFile*)mySession.OpenURL(url);
while(myHttpFile->ReadString(myData))
{
IP += myData;
}
myHttpFile->Close();
delete []myHttpFile;
mySession.Close();