HttpQueryInfo报错,该怎么处理
HttpQueryInfo报错
file1.php
- PHP code
<!--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
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include "stdafx.h"#include <stdio.h>#include <stdlib.h>#include<windows.h> #include<wininet.h> #include<iostream.h> #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( 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;}<div class="clear"> </div></iostream.h></wininet.h></windows.h></stdlib.h></stdio.h>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

linux printf is used in the command line. This command is used to format print data; the command format of printf is "printf FORMAT [ARGUMENT]...printf OPTION", where the "help" option means displaying help information, and the "version" option means Display version information.

1. Concept of using JavaNIOBuffers to interact with NIOChannel. Read data from Channel to buffers, and write data from Buffer to Channels; the three properties of Buffer must be controlled, namely capacity, position-location, and limit. 2. Instance publicstaticvoidmain(String[]args){//Generate a buffer with a length of 10IntBufferintBuffer=IntBuffer.allocate(10);for(inti=0;i

The difference between putchar and printf: 1. The parameter type of putchar is int, and the parameter type of printf is string; 2. putchar can only output one character, and printf can output multiple characters; 3. putchar cannot format output, but printf can format it. output; 4. putchar has no return value, printf returns the number of characters successfully output; 5. putchar outputs to the console, printf is not limited to output to the console; 6. performance, etc.

The difference between fprintf and printf is that the output destination is different. printf outputs to the standard output stream, while fprintf outputs to the specified file stream. Select the appropriate function to perform output operations as needed. It should be noted that the fprintf function needs to open the file through the fopen function first, and close the file through the fclose function after use. In addition, if the file opening fails or an operation error occurs, error handling is required.

Using Buffer for I/O stream operations In addition to NIO, there are two basic methods for using Java to perform I/O operations: using methods based on InputStream and OutputStream; (byte streams) using Writer and Reader. (Character stream) No matter which method is used for file I/O, if buffering can be used reasonably, I/O performance can be effectively improved.

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没问题。

图片消失如何解决先是图片文件上传$file=$_FILES['userfile']; if(is_uploaded_file($file['tmp_name'])){$query=mysql_query("INSERT INTO gdb_banner(image_src ) VALUES ('images/{$file['name'
