Solved

How can I keep the private methods and properties of the "dllexport class" in a MFC DLL secret.

Posted on 2003-10-26
2
351 Views
Last Modified: 2013-11-20
I create a MFC DLL Project using Visual C++ 6.0 and one class is declared as "class __declspec(dllexport) CHLSmSock" to be used by other applications. But  two question are raised.
  1. I have to include the ".h" file in another application when using this dll. I don't want the private methods of this class be seen by other applications, but the ".h" file of the class show the declaration of those private methods. How can I keep them secret.
   2. The types of some private properties are inner classes of the MFC DLL. So when I use the dll in another application by including the ".h" and complie the project, the shown error message tell me that some classes are undeclared. But the classes are declared in the MFC DLL.

  How can I solve  these questions?
0
Comment
Question by:Iaskyou
2 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9624848
Create a new class, and write all those functions in that class. In your DLL call appropriate functions of that class when needed.
Rosh :)
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 130 total points
ID: 9625125
To avoid including h-files fot inner classes in the client project use forward declarations and pointers:

// HLSmSock.h

class A;       // inner class forward declaration

class CHLSmSock            // exported class
{
    ...
    A* pA;     // pointer, not instance
};


// HLSmSock.cpp

#include "HLSmSock.h"
#include "A.h"                   // include inner class only to cpp-file

// create A instance in CHLSmSock constructor:
// pA = new A();
// and release it in CHLSmSock destructor




0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

22 Experts available now in Live!

Get 1:1 Help Now