摘要:
2024-05-23 服务器开发-windows-加载dll动态库
使用 LoadLibrary
cpp
HMODULE mdl = ::LoadLibrary(L"mylib.dll");
if (!mdl)
{
auto err = ::GetLastError();
std::cout << "ERROR: load VxCfgClient fail, error: " << err << std::endl;
return -1;
}
使用dll中的函数
cpp
typedef int* (*Func)(int*);
Func func =
(Func)GetProcAddress(mdl, "myFunc");
if (!func)
{
auto err = ::GetLastError();
std::cout << "ERROR: get funcfail, error: " << err << std::endl;
return -1;
}