VS工程动态加载dll

int rst = 0;
//创建dll句柄
HINSTANCE hDll;
//装载dll
//TCHAR ssleay[32] = _T("ssleay.dll");
//调试
TCHAR ssleay[32] = _T("marsdll.dll");
//TCHAR ssleay[32] = _T("..\x64\Release\marsdll.dll");
hDll = LoadLibrary(ssleay);
if (NULL == hDll)
{
DWORD dwError = GetLastError();
OutputDebugPrintf("NULL == hDll error:%d \n", dwError);

}
if (1)
{
//检索指定DLL中的输出库函数地址
typedef int(*lpCall)();
lpCall CalcLibInit = (lpCall)GetProcAddress(hDll, "StartMars");
if (NULL != CalcLibInit)
{
OutputDebugPrintf("NULL != CalcLibInit \n");
}
DWORD dwError = GetLastError();
OutputDebugPrintf("NULL == CalcLibInit error:%d \n", dwError);

}

posted @ 2021-02-03 09:45  HappyCoder_1  阅读(270)  评论(0编辑  收藏  举报