Need help to use HttpOpenRequest()

Hi,

I need help to make my program enable to download some pictures. I use the function HttpOpenRequest() that allow to download text files by default. I saw in the MSDN that if I want to download pictures I need to specify the 6th parameter with a " Pointer to a null-terminated array of strings that indicates media types accepted by the client."

I tried lots of things to make it works, but it always fail and it downloads the 404 error web page. Here is the code I use to do my tests.

#include <windows.h>
#include <wininet.h>
#include "OFile.h" // class that manage file creation

void main()
{
HINTERNET hInternet;
HINTERNET hHttpSession;
HINTERNET hHttpRequest;
char *Buf;
char BufSizeText[1000];
DWORD BufSizeTextSize = 1000;
DWORD BufSize;
DWORD ReadSize;
const char *type[] = {"text/*", "image/*", NULL};

hInternet = InternetOpen(
"Get Image File",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
0);

hHttpSession = InternetConnect(
hInternet,
"www.dev-archive.com",
INTERNET_DEFAULT_HTTP_PORT,
NULL,
NULL,
INTERNET_SERVICE_HTTP,
0,
0);

hHttpRequest = HttpOpenRequest(
hHttpSession,
"GET",
"cg-logo.gif",
NULL,
"http://www.dev-archive.com/forum/images/",
type,
0,
0);

HttpSendRequest(
hHttpRequest,
NULL,
0,
NULL,
0);

HttpQueryInfo(
hHttpRequest,
HTTP_QUERY_CONTENT_LENGTH,
BufSizeText,
&BufSizeTextSize,
NULL);

BufSize = atol(BufSizeText);
Buf = (char *)GlobalAlloc(GMEM_FIXED, BufSize);

InternetReadFile(
hHttpRequest,
Buf,
BufSize,
&ReadSize);

OFile *myFile = new OFile(strlen(Buf)); // this create a file in write mode

myFile->Fill(Buf); // this fill the file with the content of the buffer

GlobalFree(Buf);
InternetCloseHandle(hHttpRequest);
InternetCloseHandle(hHttpSession);
InternetCloseHandle(hInternet);
}

If you can see my mistake, thanks to show me where it is.
Thanks a lot.
[2252 byte] By [DogeZaemon] at [2007-11-18 2:14:13]