添加头文件
#include <ace/DLL.h> #include <ace/DLL_Manager.h>
定义函数接口
typedef long (*PFN_TEST)(const char* szName); PFN_TEST g_pfnTest = NULL;
加载动态库(dll/so)
ACE_TCHAR szDName[128] = { 0 }; strncpy(szDName, D_NAME, 128); ACE_DLL m_hD; int nRet = m_hD.open(szDName); if(nRet != 0) { cout << "ERROR." << endl; m_hD.close(); return nRet; }
调用动态库函数
g_pfnTest = (PFN_TEST)m_hD.symbol("Test"); if(g_pfnTest != NULL) { g_pfnTest ("wjshan0808"); }
时间: 2024-11-06 10:17:33