18,356
社区成员
发帖
与我相关
我的任务
分享
int APIENTRY _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine, int nCmdShow)
{
TCHAR *p=L"http://1.2.3.4:9090/mysoft/azAction.action?ip=127.0.1.3&name=1";
TCHAR *h=L"Content-Type: application/x-www-form-urlencoded";
DWORD dwSize = 0;
DWORD dwDownloaded = 0;
LPSTR pszOutBuffer;
BOOL bResults = FALSE;
HINTERNET hSession = NULL,
hConnect = NULL,
hRequest = NULL;
// Use WinHttpOpen to obtain a session handle.
hSession = WinHttpOpen( L"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322",
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);
// Specify an HTTP server.
if (hSession)
hConnect = WinHttpConnect( hSession, L"1.2.3.4",
/*INTERNET_DEFAULT_HTTPS_PORT*/9090, 0);
// Create an HTTP request handle.
if (hConnect)
hRequest = WinHttpOpenRequest( hConnect, L"POST", L"/mysoft/azAction.action?",
NULL, L"Content-Type: application/x-www-form-urlencoded",
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_SECURE);
//听说要加http头自己加的
WinHttpAddRequestHeaders(hRequest,h,lstrlen(h),0);
// Send a request.
if (hRequest)
bResults = WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0, p, lstrlen(p),
lstrlen(p), 0);
DWORD n=GetLastError();
// End the request.
// Close any open handles.
if (hRequest) WinHttpCloseHandle(hRequest);
if (hConnect) WinHttpCloseHandle(hConnect);
if (hSession) WinHttpCloseHandle(hSession);