我写了好简单的几行代码,在得到网页内容大小的那行出了问题,我的length字符数组里的数是30400070,本来是3407,可不知道中间怎么多插了个0,结果得到的len是3
h_Internet = InternetOpen( NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
h_openInter = InternetOpenUrl(h_Internet,TEXT("http://www.baidu.com/"),NULL,NULL,NULL,NULL);
dw = sizeof(Length);
HttpQueryInfo(h_openInter,HTTP_QUERY_CONTENT_LENGTH, (LPVOID)Length, &dw, NULL); len = atoi(Length); pBuf = new char[len+1]; InternetReadFile(h_openInter,pBuf,len,&dw);
h_Internet = InternetOpen( NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
h_openInter = InternetOpenUrl(h_Internet,TEXT("http://www.baidu.com/"),NULL,NULL,NULL,NULL);
dw = sizeof(Length);
HttpQueryInfo(h_openInter,HTTP_QUERY_CONTENT_LENGTH, (LPVOID)Length, &dw, NULL); len = atoi(Length); pBuf = new char[len+1]; InternetReadFile(h_openInter,pBuf,len,&dw);
解决方案 »
- VC访问ORACLE 8数据库,遭遇Ora-02041:客户端数据库未启动一个事务
- malloc出错了。
- 用boundChecker检查vc程序时,需要在项目中怎么设置,才能指出具体的出错代码行??
- 问一个lee病毒的问题
- 急!请帮帮忙!!!
- 我自己写了View类中的OnPrint函数输出一些文本,在打印预览时显示正确,可是到打印机上就全是横线和黑方块了,为什么会这样?
- 小问题:给一个字符串,如何判断是一个ip地址,还是一个主机名称?
- 为什么toolwindow不显示标题栏图标??
- 如何让进程退出的时候删除执行文件
- 再问!如何实现一个窗口从左边缓慢移入到屏幕中央!
- 服务器与客户端用socket通信,如果服务器故意断开,有什么方法可以实现?
- 重新开贴,高分请教音频录制问题!
Pointer to a variable that contains, on entry, the size in bytes of the buffer pointed to by lpvBuffer. When the function returns successfully, this variable contains the number of bytes of information written to the buffer. In the case of a string, the byte count does not include the string's terminating null character.问题很大啊
HttpQueryInfo(h_openInter,HTTP_QUERY_CONTENT_LENGTH, (LPVOID)Length, &dw, NULL);
MSDN上第4个参数的说明,你填进去的是dw的地址,dw=4,也就是说第3个参数接收buffer的长度是4,但你这样(LPVOID)Length是指向哪里呢?把Length里的内容作为了地址,万幸还没有出错。而且MSDN上说第4个参数the byte count does not include the string's terminating null character,不包括结尾的0,那么4-1=3就这样来的
没看明白你写的