I am having a dll in which I have some managed classes. I need to set the attribute values of managed class from the .exe and pass it to the dll. But dllexport function doesnt accept the managed class as parameter. Is there any other way to do it?
If your .dll is "plain" dll (not some COM class or .NET assembly), you cannot expose classes. You can, however expose something like
void* CreateInstance(int param1, const char* param2);
int DoSomeMegaWork(void* instance, const int* paramZ);
Implementation will be void* CreateInstance(param1, param2) { YourClass* instance = new YourClass(param1); //well, whenever instance.DoSomeWork(param2); return instance; }
int DoSomeMegaWork(void* _instance, const int* paramZ)
{
YoutClass* instance = (YourClass*) _instance;
return instance.DoSomeMegaWork(paramZ);
}
Don't forget to destroy instances in the same .dll
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.