动态加载DLL导出的数据

Load DLL exported data dynamically

本文关键字:数据 加载 DLL 动态      更新时间:2023-10-16

是否有导出数据的GetProcAddress版本?

我想这样做:

Mydll.cpp:

MyDataType::MyDataType(long, wchar_t*)
{
    //Dummy code
    this->temp = 3;
}
__declspec(dllexport) MyDataType Here(50, L"random text");

MyClient.cpp:

int main(void)
{
    HINSTANCE hData = LoadLibrary("MyDll.dll");
    reinterpret_cast<MyDataType*>(GetDataAddress(hData, "Here"))->DoSomething();
}

也就是说,定义UDT("MyDataType")的导出数据("Here"),并在动态加载DLL时获取其地址。这可能吗?

msdn页面说"从指定的动态链接库(DLL)中检索导出函数或变量的地址。"-即it should Just Work(tm)