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");
}
}
windows LoadLibrary使用示例
最新推荐文章于 2025-02-09 15:23:23 发布