动态加载DLL导出的数据 [英] Load DLL exported data dynamically

查看:125
本文介绍了动态加载DLL导出的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there a version of GetProcAddress for exported data?

我想做类似的事情:

Mydll.cpp:

Mydll.cpp:

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

MyClient.cpp:

MyClient.cpp:

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

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

That is, define an exported data ("Here") of UDT ("MyDataType"), and them obtain its address when the DLL is dynamically loaded. Is this possible?

推荐答案

msdn页面显示从指定的动态链接库(DLL)检索导出的函数或变量的地址." -即应该可以正常工作(tm)

the msdn page says "Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL)." - ie it should Just Work(tm)

这篇关于动态加载DLL导出的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆