loading class methods from dll

Started by
1 comment, last by uNiQue0815 21 years, 4 months ago
is there a way to load a class (its methods) from dll ? i''m talking about doing this ''by hand''... with GetProcAddress... how do i have to export a class/its methods and how do i use GetProcAddress right ? or doesn''t that work at all ? how are class-methods loaded when using an import-library ? are they linked statically ? don''t think so, but i don''t know for sure... if they are linked dynamically, there has to be a way to do it manually, right ?
Advertisement
One solution is to cast a pointer to the class object and call its member function. Another solution is to make the member function global.

Kuphryn
quote:Original post by uNiQue0815
is there a way to load a class (its methods) from dll ?

the easier solution is to make all functions virtual, create an interface class that is implemented by dll, and have dll export a function returning a pointer to an object of that class created by the dll (this is how COM works).

the other way is to import member functions by name with GetProcAddress, and then use pointers to member functions to call them. this works, but you''ll need to bother with mangled function names, so this method is far from something you want to deal with, considering it offers no speed benefits over the first one - you still need double jump.

This topic is closed to new replies.

Advertisement