现在的位置: 首页 > 综合 > 正文

通过Load Library加载标准DLL

2012年12月16日 ⁄ 综合 ⁄ 共 406字 ⁄ 字号 评论关闭
1)HMODULE hm = LoadLibrary("c:\test\test.dll"); //假设DLL路径是c:\test\test.dll
2)PFUNC pFunc = (PFUNC)GetProcAddress((HINSTANCE)hm, _T("fun1")); //Find a function and use it
   if (pFunc != NULL)
    {
      int n = pFunc();      //typedef int (*PFUNC)(void);
...
    }
3)FreeLibrary((HMODULE)hm);   //Finally, don't forget to free it.

See Plug-in Architecture Framework for Beginners at http://www.codeguru.com/Cpp/misc/misc/plug-insadd-ins/article.php/c3879

抱歉!评论已关闭.