vc 动态链接库动态加载的全过程

一.创建动态链接库 

    #ifndef DLL_IMPORT

    #define DLL _declspec(dllexport)

    #else

    #define DLL _declspec(dllimport)

    #endif

    #define COMP_C extern "C"

    COMP_C void DLL fun()

    {

      cout<<"this is test"<<endl;

    }

    HINSTANCE hIns =LoadLibrary("./testDll.dll");

    typedef void (*lpfun) ();

    if(hIns==NULL)

    {

      messageBox("加载dll失败!");

      return ;

    }

    lpfun test_fun;

    test_fun =(lpfun)GetProcAddress(hIns,"fun");

    if(test_fun!=NULL)

    {

      test_fun();

    }

    FreeLibrary(hIns);

以上就是vc动态库动态加载的全过程。

    

posted @ 2013-01-04 12:58  Lost_Heart  阅读(557)  评论(0编辑  收藏  举报