1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#define _WIN32_WINNT 0x600
#include <stdio.h>
#include <windows.h>
#include <wininet.h>
#pragma comment (lib,"wininet")
int main()
{
HINTERNET hInternet = InternetOpen("AddyApp",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
HINTERNET hSession = InternetConnect(hInternet,"localhost",80,NULL,NULL,INTERNET_SERVICE_HTTP ,0,0);
HINTERNET hReq = HttpOpenRequest(hSession,"GET","/wininettest/server.php",NULL,NULL,NULL,0,0);
char name[50] = "Kazo";
char num[50] = "0809xxxxxxxxxxxx";
char pBuf[1024]="name=%s&num=%s";
HttpSendRequest(hReq,NULL,0,pBuf,strlen(pBuf));
DWORD dwAvailable,dwBytesRead;
char pOutBuf[1024];
char* pTempBuf=pOutBuf;
while(InternetQueryDataAvailable(hReq,&dwAvailable,0,0) && dwAvailable != 0)
{
DWORD dwBytesRead;
InternetReadFile(hReq,pTempBuf,dwAvailable,&dwBytesRead);
pTempBuf += dwBytesRead;
}
InternetCloseHandle(hReq);
InternetCloseHandle(hSession);
InternetCloseHandle(hInternet);
printf("Sent Successfully \n");
system("pause");
}
|