1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
int Newlength = WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsURL.c_str(), -1, NULL, 0, NULL, NULL);
// allocate buffer
char* buffer = new char[Newlength]; // this INCLUDES terminating NULL if you use -1 argument to WideCharToMultiByte()
WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsURL.c_str(), -1, buffer, Newlength, NULL, NULL);
DWORD dwError = GetLastError();
HOSTENT *pHostEnt;
int **ppaddr;
SOCKADDR_IN sockAddr;
char* addr;
pHostEnt = gethostbyname(buffer);
//Added this on the second run, same results////////////////
ppaddr = (int**)pHostEnt->h_addr_list;
sockAddr.sin_addr.s_addr = **ppaddr;
addr = inet_ntoa(sockAddr.sin_addr);
////////////////////////////////////////////////////
delete [] buffer; // free memory
printf("\n Current Website IP:%s", buffer);
| |