Async WinINet - HttpSendRequest() Crashes Program

Well, I don't exactly know what to post for this one....

So, I have this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
char* msg1=const_cast<char*>("Connecting To Server....");
SendMessageA(ClientArea, AM_CLIENTWINDOW_STARTTEXT_CHANGE, 500, (LPARAM)(LPCTSTR)msg1);
std::string defstr;
std::stringstream vstrm;
std::string vstr;
DWORD_PTR context=2;
HINTERNET c=InternetOpen("App", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
if(c==NULL)
{
	ErrorExit("HINTERNET c");
	return 0;
}
InternetSetStatusCallback(c, (INTERNET_STATUS_CALLBACK)iNetStat);
HINTERNET ws=InternetConnectA(c,"dmailserver01.site40.net",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
//HINTERNET ws=InternetOpenUrl(c, "dmailserver01.site40.net", NULL, 0, INTERNET_FLAG_RELOAD | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_NO_CACHE_WRITE, context);
if(ws==NULL)
{
	ErrorExit("HINTERNET ws");
	return 0;
}
std::string rtypestr="POST";
std::string versionstr="HTTP/1.1";
const char* fn="/connect.php";
const char* rtype=rtypestr.c_str();
const char* version=versionstr.c_str();
PCTSTR accept[]={"text/html", "application/xhtml+xml", "application/xml;q=0.9", "image/webp", NULL};
HINTERNET h=HttpOpenRequestA(ws, rtype, fn, version, *accept, NULL, INTERNET_FLAG_CACHE_IF_NET_FAIL, context);
if(h==NULL)
{
	ErrorExit("HINTERNET h");
	return 0;
}
BOOL res=HttpSendRequestA(h, NULL, 0, NULL, 0);
if(res==false)
{
	ErrorExit("res");
}
//InternetCloseHandle(h);
//InternetCloseHandle(ws);
//InternetCloseHandle(c);
break; //see below 


The above code is in a switch case.

Well, I run the program, and HttpSendRequest sends only the first of ~20 status messages, HANDLE_CREATED, before crashing the program.
No Compiler Errors.
No Debugging Info.
Nada from GetLastError.
None of my research tells me anything.

Any ideas on what to do?

Info:
IDE: Orwell Dev-C++
Compiler: TDM-GCC 4.8.1 32-bit
OS: Windows 8.1 32-bit

--UPDATE 1--
I've managed to figure out that HttpSendRequest isn't sending the Handle Created, it is the InternetOpen that sends it.

--UPDATE 2--
I've been able to isolate an error: 1008 - An attempt was made to access a token that does not exist.
Last edited on
To anybody in the future:
1) Make sure your IntenetStatusCallback function is void CALLBACK, not just void.
2) Do not WaitForSingleObject the request completion event (If you set one).

To Microsoft:
Please, please, please use more descriptive error codes!
Topic archived. No new replies allowed.