Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

GetProcAddress() of DLL class member functions?

Posted on 1998-03-20
4
2,010 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 37
Doc'in system (example?) BA 7 115
sumHeights2  challenge 7 116
Capture logon name 13 87
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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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