1
导出的数据是否存在GetProcAddress版本?动态加载DLL导出的数据
我想这样做:
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”),并且它们在动态加载DLL时获取它的地址。这可能吗?
msdn页面显示“从指定的动态链接库(DLL)中检索导出的函数或变量的地址。” - 即它应该只是工作(TM) – pm100
我要同意pm100。 当您在运行时加载DLL时,您描述的过程的哪些部分不做? – Phixle
检查mydll.cpp的输出。我不知道'__declspec(dllexport)'放在一个名称上是什么类型的,但可能是某种东西,所以GetProcAddress调用将无法使用“Here”找到该符号,并且您需要使用完整的名称。 – 1201ProgramAlarm