#include<stdio.h> #include<conio.h> #include<winsock2.h> #include<windows.h> #include<stdlib.h> #pragma comment(lib"ws2_32.lib") // this function is to get local ip address void CheckIP(void) //define CheckIP() function to get IP WSADATA wsaData; char name[255]; char *ip; PHOSTENT hostinfo; //instruct MAKEWORD() get Winsock vision if ( WSAStartup( MAKEWORD(2,0), &wsaData ) == 0 ) { if( gethostname ( name, sizeof(name)) == 0) { if((hostinfo = gethostbyname(name)) != NULL) { ip = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list); printf("\n\n Your IP IS:%s\n\n",ip); } } WSACleanup( ); } } int main(void) { CheckIP(); system("route -p add 0.0.0.0 mask 0.0.0.0 ip"); // Maybe it's wrong, but how can correct it ? help! /* for example: if the ip that I get is 192.168.0.1. system ("route -p add 0.0.0.0 mask 0.0.0.0 192.168.0.1 ")*/ getch(); return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)