Skip to main content
gamedev.net
🔒 Locked

loading class methods from dll

Started by uNiQue0815 1 reply 400+ views
Original Post
uNiQue0815
uNiQue0815
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 ?
kuphryn
kuphryn
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
niyaw
niyaw
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.