Sign in to follow this  

A Few DLL Questions

This topic is 3595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok well im looking into makeing some runtime DLL's for some software im doing that will be a editing compent to future game idea's and project. Iv read a post on GameDev about writing DLL's with classes however it was not very far in depth and mostly just had a bunch of code. I understood the concept but i tryed a simple version of a dll with useing the GetProcAdress function however i could not get the functions to be imported VIA a runtime loaded DLL. Well to be more specific my compiler is VC++ Express if someone could give me an example or a relavent well documented resource invovlving the use of a class in a dll id appreceate it. I wish to have a runtime loaded dll because it would be easyer to do updates for the software instead of having to release a whole new exe i could just realease a new DLL for the update. If you have a class in a dll and you import its function VIA an interface witch i still can't do because i don't understand it enough, Does the constructor and deonstructor still function normaly with in the DLL. This si a complexe question basicaly when the DLL is loaded does the code run in the DLL or is it copyed into your Program that uses the DLL. If there are any imporvments or clarifications to what i am trying to convy please let me know. Regards Jouei.

Share this post


Link to post
Share on other sites
Short answer there is no simple way to export a class from a DLL short of using macros and template classes to allow you to instantiate the class from within the DLL itself. GetProcAddress returns the address of an exposed function/variable within the DLL itself which is prefixed with either __declspec( dllexport ) or defined in a .def file. I am not going to go into specifics on how I export my classes from a DLL as without a more thorough understanding of the process my template classes and sample code would make next to no sense as it is. The following link explains the proper use of the GetProcAddress() function:

http://msdn2.microsoft.com/en-us/library/ms683212.aspx

You can try reviewing this link for how an instance of a class can be exported from the DLL and as you'll notice a method must be exposed to call the object's constructor and the DLL therefore the object is created in the DLL's memory space and the application utilizing it is provided a pointer to this object:

http://www.codeguru.com/cpp/w-p/dll/importexportissues/article.php/c123/#more

Hope this helps.

Share this post


Link to post
Share on other sites
Well beliveably or not your answered most of my questions its not so much actualy exporting the class itself as thats not so important but being able to use it and i was not sure if the dll itself had memorie or if the code itself was just copyed over from the dll so you answered all my questions ether intentonaly or other wise so thank you very much from the code guru link i should beable to get it to work and fingure it out thank you again

Regards Jouei.

Share this post


Link to post
Share on other sites
Quote:
Original post by Jouei
Well beliveably or not your answered most of my questions its not so much actualy exporting the class itself as thats not so important but being able to use it and i was not sure if the dll itself had memorie or if the code itself was just copyed over from the dll so you answered all my questions ether intentonaly or other wise so thank you very much from the code guru link i should beable to get it to work and fingure it out thank you again

Regards Jouei.

You're welcome, good to hear this helped!

Share this post


Link to post
Share on other sites

This topic is 3595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this