InternetSetStatusCallback() returning NULL

Started by
3 comments, last by Teric 18 years, 7 months ago
I'm trying to run WinINet functions asynchronously within a class called FileDownloadManager. In the class declaration (FileDownload.h), I've got the following definition:

private:
//Handle to an internet session
HINTERNET m_hInternet;

public:
//Callback function for handling internet download messages
static void __stdcall s_internet_callback_func( HINTERNET hInternet,
    DWORD_PTR dwContext,
    DWORD dwInternetStatus,
    LPVOID lpvStatusInformation,
    DWORD dwStatusInformationLength );

//Pointer to the callback function
INTERNET_STATUS_CALLBACK 	m_ISCallback;


In the class definition (FileDownload.cpp), I use the following:

//Start up an internet session
m_hInternet = InternetOpen("MyWinINet",
    INTERNET_OPEN_TYPE_PRECONFIG,
    NULL,
    NULL,
    INTERNET_FLAG_ASYNC);

m_ISCallback = InternetSetStatusCallback( m_hInternet,
    (INTERNET_STATUS_CALLBACK)s_internet_callback_func );


When I debug through the code, the m_hInternet handle gets set up just fine. However, when I make the call to InternetSetStatusCallback, the function always returns NULL. The docs say that a NULL returned from InternetSetStatusCallback means that the status callback function was not previously defined. I don't understand this--I've clearly defined s_internet_callback_func in the class declaration. Am I doing something wrong? Would appreciate any insight on how to fix this problem. Thanks in advance!
I am always open to feedback, positive or negative...
Advertisement
MSDN:
Quote:
Returns the previously defined status callback function if successful, NULL if there was no previously defined status callback function, or INTERNET_INVALID_STATUS_CALLBACK if the callback function is not valid.

Yes, it must return NULL at first. Just developed the same class.
Are you receiving errors that callback function is not set?
ai-blog.org: AI is discussed here.
No, I'm just getting a NULL returned from InternetSetStatusCallback().
I am always open to feedback, positive or negative...
Quote:Original post by Teric
No, I'm just getting a NULL returned from InternetSetStatusCallback().


that's ok.
ai-blog.org: AI is discussed here.
Oh I GET IT now. I had not submitted any callback functions to any previous calls to InternetSetStatusCallback, so it would return a NULL indicating that there was no previously submitted callback function. It still accepts the function that I gave it.

Geez the docs were confusing on that one.
I am always open to feedback, positive or negative...

This topic is closed to new replies.

Advertisement