geting class functions in dll

Started by
4 comments, last by Kackurot 18 years, 6 months ago
Does anyone know how to retrive class functions from dll? I need to know how to retrieve class functions from a dll, but I don't know the syntax. Its easy for me to get none class functions using GetProcAddress. If anyone knows, can you please show me an example of it. thanks
[file:///C:/My%20Documents/kack.gif]
Advertisement
if the functions are exported then you just need to instantiate an instance of the class and call them like you would any other...If they are not exported then there is nothing you can do to use them and you will get linker errors, unless they are inlined in the header file.

this following is an example (assuming MSVC)
// some dll's header file#ifdef _WINDOWS#   ifdef THISDLL_EXPORTS #      define EXPORT __declspec(dllexport)#   else#      define EXPORT __declspec(dllimport)#   endif#else#   define EXPORT#endif// all functions will be exported in this caseclass EXPORT FullyExportedClass{public:   FullyExportedClass(void);   ~FullyExportedClass(void);};// in this case you would export whichever functions you want to be // available outside the dllclass PartiallyExportedClass{   public:     EXPORT PartiallyExportedClass(void);     EXPORT ~PartiallyExportedClass(void);   private:     void NoneExportedFunction(void);};// if everything is inlined then the functions will be visible// anywhere this header is includedclass FullyInlinedClass{    public:       FullyInlinedClass(void)       {         //etc...       }       ~FullyInlinedClass(void)        {        }};


In cases where the stuff is not inlined (most cases) you need to link to the dll's lib file while compiling and make sure the dll file is in the same directory as, or in a path directory, for your executable/dll to access it.
moe.ron
Umm... I wanted to know how to get them dynamicly. I already know that method, the one u are showing me. I want to call getprocadress and get them that way. So if u know how to do it that way,please let me know.
[file:///C:/My%20Documents/kack.gif]
Here you have a good article for run time linking dlls.
----------------------------"I refuse to answer that question on the grounds that I don't know the answer"-- Douglas Adams (1952 - 2001)
Just a summary of the above:
You can't. (get class functions)
You can only get a class instance from a DLL. You do this by having both your application and the dll having the same ABC, which will define the functions you can use. They (the plugin makers) will derive off this ABC and provide it to your application through a C function that you get using GetProcAddress that will create their derived class.

For more in depth information, see the link frecco2k put up.
----Erzengel des Lichtes光の大天使Archangel of LightEverything has a use. You must know that use, and when to properly use the effects.♀≈♂?
Ok, thanks thats what I figured, just stuck with one more about geting functions. What if the function was in a namespace, how would u get them, or can u ? I was writing a math lib that had math namespace and a math_SIMD name space. So is there a way to get them from namespaces or do I just have to forget about that idea?
[file:///C:/My%20Documents/kack.gif]

This topic is closed to new replies.

Advertisement