Archived

This topic is now archived and is closed to further replies.

Snatch

load a Class from a DLL ?

Recommended Posts

Snatch    128
Is it possible with Visual Studio .Net to put a Class in a DLL and instance it an other executable ??? If it is possible at runtime, it it time consuming ? Can me apply this method to load every kind of object a game can use ? (CModel CSolidModel CSoundGenerator CSoundEnvironment ...)

Share this post


Link to post
Share on other sites
Sure you can, just declare the class with __declspec(dllexport) in the dll and __declspec(dllimport) in the executable. I''m not sure how time consuming it is, but I expect its not too much of a performance hit.

Share this post


Link to post
Share on other sites
Maega    707
Do you want to dynamically load it or use an import library?

If you want to do an import library, use what Duke said.

If you want to do it dynamically, you can do it with abstract interfaces

Share this post


Link to post
Share on other sites
JimC    122
I normally use COM-style interfaces. (Otherwise your DLL will likely be exporting a zillion member functions from all the classes)
It shouldn''t be too time consuming (for modern processors).

Share this post


Link to post
Share on other sites
Armand    164
There are a few ways of doing it. So yes, it is posible.

Maega advice works well. And if you go for the Abstract interfaces, then I can atest that it works, even when a C++ DLL is loaded by a Delphi App.



Armand
-------------------------
It is a good day to code.

Share this post


Link to post
Share on other sites