Skip to main content
GameDev.net gamedev.net
🔒 Locked

DLL Function Call

Started by BeMe Aug 6, 2002 at 8:00 AM 3 replies 250+ views
Original Post
BeMe
BeMe
Hello, I have been attempting to modulaize my code and now I have ran into a problem. I have a dll called Client. This dll holds all of the game logic. I need to allow this dll to tell the main executable to do something such as DrawText(). I have attempted to pass a class pointer to the DLL, but this has not worked. Could someone please show me how I can get a class pointer into a dll so that I may make function calls into the main exe?
JonStelly
JonStelly
You need to be more specific. What do you mean it didn''t work?

Normally when passing classes from EXE to DLL it will be easiest if you define a base class (or interface) in the DLL, then derive from that class in your executable.
BeMe
BeMe
Well Actually What I am doing is creating an interface class within the main exe and including the class header file within the dll. I failed to include "virtual" in my function definitions and I was getting linker errors. Now I have corrected this and it works just like it was suppose to.

Thank you for your help.
JonStelly
JonStelly
Alrighty. But a suggestion... It might make more sense to define the base class / interface in the DLL. That way the DLL could be used in other applications without requiring you to copy that header file around to the new projects etc...
BeMe
BeMe
Thank you for the idea. I will take a look at that. Never crossed my mind to reverse it.

Thanks again.

Topic Locked

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

Sign in to reply to this topic.