Hello,

I would like to download a file from the internet. As the file is really great, I want to have a progressbar showing the status. For that, I have to know the size of the file.

That is my plan. But actually, my computer crashes if I use the HttpQueryInfo-API.
I know this is a really great question, but maybe someone here has used that API before.



.data
szUrl DB "www.cvdb.de", 0
szA DB "blablabla", 0
szHead DB "HEAD", 0
szHttp DB "HTTP/1.1", 0
szInfoSite DB "/avb/avbm/info.dat", 0
szBuffer DB 128 DUP(" "), 0
szUserAgent DB "Download", 0
szQueryInfo DB 1025 DUP(0)
szHttpOK DB "200", 0
szContent DB "Content-Length:", 0

.data?
hOpen DD ?
hInternet DD ?
hHttpOpen DD ?
hReturn DD ?

.code

; .....

GetFilesThread PROC

invoke InternetOpen,
ADDR szUserAgent,
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
0

mov hOpen, eax

invoke InternetConnect,
hOpen,
ADDR szUrl,
INTERNET_DEFAULT_HTTP_PORT,
NULL,
NULL,
INTERNET_SERVICE_HTTP,
0,
0

mov hInternet, eax

cmp hInternet, 0
je ConnectionFailed

invoke HttpOpenRequestA,
hInternet,
ADDR szHead,
ADDR szInfoSite,
ADDR szHttp,
NULL,
0,
INTERNET_FLAG_RELOAD,
0

mov hHttpOpen, eax

cmp hHttpOpen, 0
je ConnectionFailed

invoke HttpSendRequestA,
hHttpOpen,
NULL,
0,
0,
0

mov hReturn, eax

cmp hReturn, 0
je ConnectionFailed

invoke RtlZeroMemory,
OFFSET szQueryInfo,
1024

invoke HttpQueryInfoA, ;here, it crashes!! <<
hHttpOpen,
HTTP_QUERY_STATUS_CODE,
ADDR szQueryInfo,
1024,
0

invoke StrComp,
OFFSET szQueryInfo,
OFFSET szHttpOK

cmp eax, TRUE
jne ConnectionFailed

invoke RtlZeroMemory,
OFFSET szQueryInfo,
1024

invoke HttpQueryInfoA,
hHttpOpen,
HTTP_QUERY_RAW_HEADERS,
ADDR szQueryInfo,
1024,
0

invoke InString,
1,
OFFSET szBuffer,
OFFSET szContent

.if eax >= 0

invoke SetWindowText,
hLabel,
OFFSET szA
.endif

invoke EnableWindow,
hButton2,
TRUE

jmp Done

ConnectionFailed:
invoke SetWindowText,
hLabel,
OFFSET szNoInternet

Done:

invoke InternetCloseHandle,
hOpen

invoke InternetCloseHandle,
hHttpOpen

invoke InternetCloseHandle,
hInternet

ret


ret

GetFilesThread ENDP

StrComp PROC String1:DWORD,
String2:DWORD

mov eax, String1
mov ecx, String2

dec eax
dec ecx

StrComp1: inc eax
inc ecx

mov dl, [eax]
mov dh, [ecx]

cmp dh, dl
jne NotEqual

cmp dh, 0
je Equal

jmp StrComp1

NotEqual: mov eax, FALSE
ret

Equal: mov eax, TRUE
ret

StrComp ENDP


I am looking forward to any answers!

Regards,
Claus
Posted on 2004-06-27 10:49:10 by ndn4u
OK,

I think I got the error.

HttpQueryInfoA wants a memory address where there is a pointer to the buffer size, so it can put in how many bytes were needed.

Regards,
Claus
Posted on 2004-06-27 11:48:27 by ndn4u