Solved

GetProcAddress() of DLL class member functions?

Posted on 1998-03-20
4
1,931 Views
Last Modified: 2013-11-20
I am having trouble with runtime linked DLL's. The problem is that I can called global functions inside the DLL project, but if I make a function inside the WinApp class (for example) it can't seem to get the procedure address?
Are there any examples around which show runtime linked member functions of classes? (not just c functions).
0
Comment
Question by:jpronk
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1317119
While you can do that, the work involved is much more complicated. The biggest reason is that the member functions require a hidden this parameter which indicates the object the function is associated with. You don't have this in the declaration because it is generated by the compiler behind the scene.

Typically, if you have a member function you want to expose, you expose the entire class and not just one member function.


0
 

Author Comment

by:jpronk
ID: 1317120
So how do you get the address of the object then at runtime?
Currently I have by-passed the problem by interfacing via global functions, which seems to  work pretty good. Except I am not sure its the best way to go about things.
The DLL's are actually plugins to this software I am building.

thanks for your help
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1317121
You provide a global exported function who returns a pointer to the object. For example,

  _declspec(dllexport) IFoo* CreateFoo()
  {
    IFoo* foo = new IFoo;
    return foo;
  }

  _declspec(dllexport) BOOL CleanupFoo(IFoo* foo)
  {
    delete foo;
    return TRUE;
  }

0
 

Author Comment

by:jpronk
ID: 1317122
Oh ok, yeah I think I did that a while back. Is there much of an overhead on calling a member function rather than a global funtion (is one faster than the other?).
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now