Click here to Skip to main content
15,881,424 members
Articles / Mobile Apps / Windows Mobile

An Asynchronous HTTP Request WinINet Wrapper in C++

Rate me:
Please Sign up or sign in to vote.
4.90/5 (45 votes)
25 Aug 2011CPOL2 min read 134K   8.8K   172  
An asynchronous HTTP download class for C++
#include "stdafx.h"

class CMyHttpManager : public FCHttpRequestManager
{
private:
    virtual void OnAfterRequestSend (FCHttpRequest& rTask)
    {
    }
    virtual void OnAfterRequestFinish (FCHttpRequest& rTask)
    {
    }
};

static CMyHttpManager   * g_obj = NULL ;

BOOL APIENTRY DllMain (HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    /*
        don't delete g_obj in DLL_PROCESS_DETACH,
        because of WaitForSingleObject will can't receive signal of thread finish at this time,

        so, user must call Load and UnLoad
    */
    return TRUE ;
}

extern "C" __declspec(dllexport) void Load()
{
    g_obj = new CMyHttpManager ;
}

extern "C" __declspec(dllexport) void UnLoad()
{
    delete g_obj ;
    g_obj = NULL ;
}

extern "C" __declspec(dllexport) void DownloadUrl (LPCWSTR url)
{
    g_obj->AddDownload(url) ;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader PhoXo
China China
graduate from University of Science and Technology of China at 2002.

Now I work at www.phoxo.com.

Comments and Discussions