typedef int(*HA_GetVersion_t)(); //定义函数指针类型
void TestLoadDll()
{
HINSTANCE hDll; //DLL句柄
TCHAR chCurDir[MAX_PATH] = {0};
GetCurrentDirectory(MAX_PATH, chCurDir);
SetCurrentDirectory(_T("E:\\libHasdk\\dll"));
hDll = LoadLibrary(_T("libHasdk.dll"));
SetCurrentDirectory(chCurDir);
if (hDll != NULL)
{
HA_GetVersion_t HA_GetVersion_p = NULL;
HA_GetVersion_p = (HA_GetVersion_t)GetProcAddress(hDll, "HA_GetVersion");
if (HA_GetVersion_p != NULL)
{
int version = HA_GetVersion_p();
printf("version = %d\n", version);
}
else
{
printf("the calling is error\n");
}
FreeLibrary(hDll);
}
else
{
printf("Load DLL Error or DLL not exist!\n");
}
}
01-14
参与评论
您还未登录,请先
登录
后发表或查看评论
05-10
1万+

02-15
1672

“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交