1 Get External IP Address 27th December 2009, 8:33 pm
Eracobengo
MITR Reader
- Code:
#include <windows.h>
#include <wininet.h>
#include <iomanip>
using namespace std;
#pragma comment(lib, "wininet");
void GetIp()
{
HINTERNET hInternet, hFile;
char Buffer[1024];
DWORD ReadSize;
FILE *File;
hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
hFile = InternetOpenUrl(hInternet, "http://whatismyip.com/automation/n09230945.asp", NULL, 0, INTERNET_FLAG_RELOAD, 0);
InternetReadFile(hFile, &Buffer, sizeof(Buffer), &ReadSize);
File = fopen("External IP.txt", "a+");
Buffer[ReadSize] = '\0';
fputs(Buffer, File);
fclose(File);
InternetCloseHandle(hFile);
InternetCloseHandle(hInternet);
}
int main()
{
ShowWindow(GetConsoleWindow(), NULL);
GetIp();
return 0;
}