WinINet access violation in HttpOpenRequest

  c++, networking, winapi, windows

I am trying to upload a file to a PHP page using WinINET. I’m getting an access violation on one of the functions, but can’t see why. I’ve built the code from an example page.

Here is the code:

HINTERNET aInternet=InternetOpen("My-Custom-Agent/1.0",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
HINTERNET aConnect=InternetConnect(aInternet,"www.myserver.com",INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);
if (aConnect)
{
    HINTERNET aRequest=HttpOpenRequest(aConnect, (const char*)"POST","myphppage.php", NULL, NULL, (const char**)"*/*{$content}",0,1);
    // ^^
    // Exception happens on this line
    // Exception thrown at 0x70C85B7C (ininet.dll) in TestApp.exe:
    // 0xC00000005: Access violation reading location 0x002A2F2A
    //
}

When I download from the server with InternetOpenURL, everything seems fine.  It just doesn't like what I'm doing somewhere here.  Any clue what I'm doing wrong?



Source: Windows Questions

LEAVE A COMMENT