Advertisement Jump to content
Sign in to follow this  

InternetSetStatusCallback() returning NULL

This topic is 4886 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:
//Handle to an internet session
HINTERNET m_hInternet;

//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

In the class definition (FileDownload.cpp), I use the following:
//Start up an internet session
m_hInternet = InternetOpen("MyWinINet",

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!

Share this post

Link to post
Share on other sites

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?

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!