I'm trying to add some rule to the route table with CreateIpForwardEntry, it's necessary to call the GetIpInterfaceEntry first on win7(see this). Here's part of my code:
#pragma warning(disable: 4996)
#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x601
//#define _WS2IPDEF_
//#define __IPHLPAPI_H__
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include <netioapi.h>
#include <iphlpapi.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#pragma comment(lib, "iphlpapi.lib")
int main() {
typedef DWORD(__stdcall *IPINTENTRY)(PMIB_IPINTERFACE_ROW);// undeclared identifier
MIB_IPINTERFACE_ROW info;
info.InterfaceIndex = 1;
memset(&(info.InterfaceLuid),0,sizeof(info.InterfaceLuid));
info.Family = AF_INET;
HINSTANCE hInst = ::LoadLibrary("Iphlpapi.dll");
IPINTENTRY pFunGetInfEntry = (IPINTENTRY)GetProcAddress(hInst,"GetIpInterfaceEntry");
DWORD dwRet = pFunGetInfEntry(&info);
}
the code doesn't compile, PMIB_IPINTERFACE_ROW is undeclared identifier, I looked into the windows headers, it's the WS2IPDEF that controls the flow. I #defined it but still now working. Anyone has been using this function? Thanks.
Is it not compiling, or compiling and not running? To get the code to compile I had to change the includes: I removed
and replaced it with
following the comments at the top of "netioapi.h".
Include the following headers in this order: