am very much new to windows currently trying to port a linux project to windows.
My application has an option to change IP-subNet-Gateway of the system with some search i was able to fina an API to it in C way
but the below mentioned works well with XP but win 7 it does not reflect.
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <winsock2.h>
#include <iphlpapi.h>
#include <stdio.h>
#include <tchar.h>
typedef long _stdcall (*inpfuncPtr)(char *szAdapterGUID,
DWORD dwDHCP,
DWORD dwIP,
DWORD dwMask,
DWORD dwGateway);
int main(void) {
HINSTANCE hLib;
inpfuncPtr in;
char c;
hLib = LoadLibrary(TEXT("iphlpapi.dll"));
;
if (hLib == NULL)
{
printf("LoadLibrary Failed.\n");
return -1;
}
in = (inpfuncPtr) GetProcAddress(hLib, "SetAdapterIpAddress");
if (in == NULL)
{
printf("GetProcAddress for SetAdapterIpAddress Failed.\n");
return -1;
}
PWSTR pszGUID = NULL;
char szGUID[] = "{6FD68F0D-4656-4428-AF32-E877FA6C1721}";
DWORD dwSize = 0;
WideCharToMultiByte(CP_ACP, 0, pszGUID, -1, szGUID, sizeof(szGUID), NULL, NULL);
in(szGUID,
0,
inet_addr("192.168.10.248"),
inet_addr("255.255.255.0"),
inet_addr("192.168.10.1"));
printf("OK oK.\n");
return 0;
}