I have a cpp file. This is in that file...
The whole code....
#include "stdafx.h"
#include <stdio.h>
#include <wchar.h>
#include <windows.h>
#include <exdisp.h>
#include <string>
#include "abc.h"
#pragma once
void EnumExplorers();
#pragma warning(disable: 4192)
#pragma warning(disable: 4146)
#import <mshtml.tlb>
#import <shdocvw.dll>
void PrintBrowserInfo(IWebBrowser2 *pBrowser) {
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
BSTR bstr;
pBrowser->get_LocationURL(&bstr);
std::wstring wsURL;
wsURL = bstr;
size_t DSlashLoc = wsURL.find(L"://");
if (DSlashLoc != wsURL.npos)
{
wsURL.erase(wsURL.begin(), wsURL.begin() + DSlashLoc + 3);
}
DSlashLoc = wsURL.find(L"www.");
if (DSlashLoc == 0)
{
wsURL.erase(wsURL.begin(), wsURL.begin() + 4);
}
DSlashLoc = wsURL.find(L"/");
if (DSlashLoc != wsURL.npos)
{
wsURL.erase(DSlashLoc);
}
wprintf(L"\n Current Website URL: %s", wsURL.c_str());
char ipSrc[20];
int Newlength = WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsURL.c_str(), -1, NULL, 0, NULL, NULL);
std::string NewLogURL(Newlength+1, 0);
int Newresult = WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsURL.c_str(), -1, &NewLogURL[0],Newlength+1, NULL, NULL);
HOSTENT *pHostEnt2;
int **ppaddr2;
SOCKADDR_IN sockAddr2;
char* addr2;
pHostEnt2 = gethostbyname(NewLogURL.c_str());
ppaddr2 = (int**)pHostEnt2->h_addr_list;
sockAddr2.sin_addr.s_addr = **ppaddr2;
addr2 = inet_ntoa(sockAddr2.sin_addr);
char currentaddress[100] = { 0 };
strcpy( currentaddress, inet_ntoa(sockAddr2.sin_addr ) );
if( currentaddress != NULL && currentaddress[0] == '\0')
{
}
printf("\n Current Website IP:%s", currentaddress);
int length = WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsURL.c_str(), -1, NULL, 0, NULL, NULL);
std::string LogURL(length+1, 0);
int result = WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsURL.c_str(), -1, &LogURL[0],length+1, NULL, NULL);
myfile << "\n Current Website URL:" << LogURL;
myfile << "\n Current Website IP:"<< addr2;
SysFreeString(bstr);
}
void EnumExplorers() {
CoInitialize(NULL);
SHDocVw::IShellWindowsPtr spSHWinds;
IDispatchPtr spDisp;
if (spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows)) == S_OK) {
long nCount = spSHWinds->GetCount();
for (long i = 0; i < nCount; i++) {
_variant_t va(i, VT_I4);
spDisp = spSHWinds->Item(va);
SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
if (spBrowser != NULL) {
PrintBrowserInfo((IWebBrowser2 *)spBrowser.GetInterfacePtr());
spBrowser.Release();
}
}
} else {
puts("Shell windows failed to initialise");
}
}</shdocvw.dll></mshtml.tlb></string></exdisp.h></windows.h></wchar.h></stdio.h>
EnumExplorers();
printf("\n Source IP: %s", ipSrc);
myfile << "\n Source IP:" << ipSrc;
EnumExplorers(); come from a header file...it returns this...
wprintf(L"\n Current Website URL: %s", wsURL.c_str());
printf("\n Current Website IP:%s", addr2);
The problem is that I need to compare the addr from the header file with ipSrc from the cpp file. How can I do this?
Thank you.