Sign in to follow this  

InternetSetStatusCallback() returning NULL

This topic is 4478 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:
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!

Share this post


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

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

This topic is 4478 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this