一个关于HttpQueryInfo的怪问题
nasco 2002-05-02 01:38:22 参考程序员杂志的内容,写了如下程序:
#include"HttpEngine.h"
#include"stdio.h"
#include"Shlwapi.h"
int CHttpEngine::StartHttpEngine(void)
{
hSession = InternetOpen("HTTPENGINE",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,NULL,0);
if(hSession == NULL)
printf("error:internet");
hConnect = InternetConnect(hSession,"www.dreamproxy.com",INTERNET_DEFAULT_HTTP_PORT,
NULL,NULL,
INTERNET_SERVICE_HTTP,0,0);
if(hConnect == NULL)
printf("error:connect");
const char *AcceptType = "*/*";
hRequest = HttpOpenRequest(hConnect,
"GET",
"nilei/nasl09b.zip",
"HTTP/1.1",
NULL,
&AcceptType,
INTERNET_FLAG_RELOAD,
0);
if(hRequest == NULL)
printf("error:request");
return 1;
}
int __fastcall CHttpEngine::GetFileSize()
{
DWORD BufferLength = 10;
DWORD dwIndex = 0;
char Buffer[1024];
BOOL RetQueryInfo = HttpQueryInfo(hRequest,
HTTP_QUERY_CONTENT_LENGTH,
Buffer,
&BufferLength,
&dwIndex);
if(RetQueryInfo == FALSE)
{
printf("Error file size");
printf("\n Buffer = %s",Buffer);
printf("\n Length = %d,Index = %d",BufferLength,dwIndex);
}
int size = StrToInt(Buffer);
return size;
}
void main()
{
CHttpEngine he;
he.StartHttpEngine();
he.GetFileSize();
}
但是HttpQueryInfo调用始终失败,问题何在???