Solved

GetProcAddress() of DLL class member functions?

Posted on 1998-03-20
4
2,118 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
[X]
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
  • 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

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

617 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