• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

HttpQueryInfo报错,该怎么处理

php 搞代码 4年前 (2022-01-23) 15次浏览 已收录 0个评论

HttpQueryInfo报错
file1.php

PHP code

<!---ecms -ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->    $file = "D:\\ReadFileTo.txt";    $handle = fopen($file, 'r');    $sContent = '';    while(false != ($a = fread($handle, 8080))){//返回false表示已经读取到文件末尾        $sContent .= $a;    }        fclose($handle);    echo "$sContent";

vc(输出file1.php):

C/C++ code

<!---ecms -ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include "stdafx.h"#include #include #include  #include  #include  #pragma comment(lib,"wininet.lib")  #define DATA_CACHE_SIZE 1024*10int main(int argc, char* argv[]){    printf("Hello World!\n");    int i = 0;    char pulr[] = "file1.php";    HINTERNET hinternet=::InternetOpen(                 "http generic",                 INTERNET_OPEN_TYPE_PRECONFIG,                 NULL,                     NULL,                 0);    if (!hinternet)    {        printf("InternetOpen\n");        system("pause");        return 0;    }    i = 1;    HINTERNET hconnect= ::InternetConnect(                <a>2本文来源gao*daima.com搞@代#码&网6</a><pre>搞gaodaima代码

hinternet, “144.20.80.27”, 8080, NULL, //lpszUsername NULL, //lpszPassword INTERNET_SERVICE_HTTP, 0, //dwFlags 0 //dwContext ); if (!hconnect) { printf(“InternetConnect\n”); system(“pause”); return 0; } HINTERNET hHttpOpenRequest=::HttpOpenRequest( hconnect, “POST”, pulr, “HTTP/1.1”, NULL, 0, INTERNET_FLAG_RELOAD, 0 ); if (!hHttpOpenRequest) { printf(“HttpOpenRequest\n”); system(“pause”); return 0; } char psHeader[] = “Content-Type: application/x-www-form-urlencoded \n\r”; if (!(HttpAddRequestHeaders( hHttpOpenRequest, psHeader, strlen(psHeader), HTTP_ADDREQ_FLAG_REPLACE|HTTP_ADDREQ_FLAG_ADD )) ) { printf(“HttpAddRequestHeaders\n”); system(“pause”); return 0; } char *strRet=””; //”Yjr|fc|zf|cym|wjf||role1|role2|role3|role4″; char pstrContent[] = “UserName=admin&Password=-1”; if (! (HttpSendRequest( hHttpOpenRequest, NULL, 0, (LPVOID)(LPCSTR)pstrContent, strlen(pstrContent) )) ) { printf(“HttpSendRequest\n”); system(“pause”); return 0; } // Get the length of the file. DWORD dwFileSize=0; DWORD dwLengthBufQuery = sizeof(dwFileSize); DWORD dwIndex=0; BOOL bQuery = ::HttpQueryInfo(hHttpOpenRequest, HTTP_QUERY_CONTENT_LENGTH |HTTP_QUERY_FLAG_NUMBER, (LPVOID)&dwFileSize/*bufQuery*/, &dwLengthBufQuery, &dwIndex) ; if (!bQuery) { printf(“HttpQueryInfo\n”); system(“pause”); return 0; } // Allocate a buffer for the file. char* buffer = new char[dwFileSize+1] ; //由于不允许HTTP写缓存,所以无需循环调用InternetReadFile DWORD dwLength=0; DWORD dwLengthOne=1; BOOL bRead=TRUE; char bufferOne[DATA_CACHE_SIZE+10]; strcpy(buffer,””); while (bRead && dwLengthOne>0) { strcpy(bufferOne,””); if (InternetReadFile( hHttpOpenRequest, bufferOne, DATA_CACHE_SIZE+1, &dwLengthOne ) ) { if (dwLengthOne>0) { memcpy(&buffer[dwLength],bufferOne,dwLengthOne); dwLength+=dwLengthOne; //接收数据包的大小和与总数据包大小比较 if (dwLength > dwFileSize) { printf(“while\n”); system(“pause”); return 0; } buffer[dwLength]=’\0′; } } } buffer[dwLength]=’\0′; //to widerchar DWORD dwSize = MultiByteToWideChar (CP_ACP, 0, buffer, -1, NULL, 0); WCHAR *wchr = new WCHAR [dwSize]; ::MultiByteToWideChar(CP_ACP,MB_ERR_INVALID_CHARS,buffer,-1, wchr,dwSize); printf(buffer);// wprintf(wchr); delete [] wchr; delete [] buffer; ::InternetCloseHandle(hHttpOpenRequest);hHttpOpenRequest=NULL; ::InternetCloseHandle(hconnect);hconnect=NULL; ::InternetCloseHandle(hinternet);hinternet=NULL; printf(“\n”); system(“pause”); return 0;}


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:HttpQueryInfo报错,该怎么处理
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址