MFC DLL (Urgent Again)

can anyone post a sample MFC DLL, and an application calling it?  Please post a working sample.  Thanks!
aztecs00Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mkprasadConnect With a Mentor Commented:
////// The following is the DLL portion!
//////File : TestDLL.h
#ifdef TESTDLL_EXPORTS
#define TESTDLL_API __declspec(dllexport)
#else
#define TESTDLL_API __declspec(dllimport)
#endif

// This class is exported from the TestDLL.dll
class TESTDLL_API CTestDLL {
public:
     CTestDLL(void);
     char* My_Func();
     // TODO: add your methods here.
};

extern TESTDLL_API int nTestDLL;

TESTDLL_API int fnTestDLL(void);

//////File : // TestDLL.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "TestDLL.h"

BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                          )
{
    switch (ul_reason_for_call)
     {
          case DLL_PROCESS_ATTACH:
          case DLL_THREAD_ATTACH:
          case DLL_THREAD_DETACH:
          case DLL_PROCESS_DETACH:
               break;
    }
    return TRUE;
}


// This is an example of an exported variable
TESTDLL_API int nTestDLL=0;

// This is an example of an exported function.
TESTDLL_API int fnTestDLL(void)
{
     return 42;
}

// This is the constructor of a class that has been exported.
// see TestDLL.h for the class definition
CTestDLL::CTestDLL()
{
     return;
}

char* CTestDLL::My_Func()
{
     return "My Name is MKPrasad";
}

////////// This is an application using the above dll.
///////// Dont forget to include the TestDLL.LIB

#include "../TestDLL.h"
#include <iostream.h>

int main(int argc, char* argv[])
{
     cout <<fnTestDLL() << endl;
     CTestDLL testDll;
     cout << testDll.My_Func() << endl;
     return 0;
}

0
 
jhanceCommented:
I suppose someone could but your track record here on EE indicates that you are quite hostile to experts who try to help you out.  Your feedback profile shows:

Last 10 Grades Given: B C B  

You seem to enjoy giving out poor grades rather than working with the experts to get the information you need.

0
 
jhanceCommented:
Not only that, but you also seem to have a bad habit of leaving unresolved questions here:

This one from way back in January 2001:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=security&qid=20060150


And this one from June 2001:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=webdevgen&qid=20143116
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
TriskelionCommented:
Are you just looking for an example of how to call functions in a DLL from an MFC app?

Are you looking for extensions to MFC?

Does the DLL have to use MFC functions?

If it calls AfxMessagebox, does that suffice?
0
 
jhanceCommented:
mkprasad,

By all means!  Encourage this user's poor behavior!
0
 
mkprasadCommented:
This is not to encourage him,
He might be in need....
and anyway you have warned him about his bad behaviour!
As an expert(adult)he must have received it in proper sense.
What do u say Mr.aztecs00?
0
 
jhanceCommented:
>>He might be in need....

If he's in need why does he:

1) Give experts "C" grades rather than asking for more information.

2) Leave questions hanging without resolution.

Takeing care of either of the above costs NOTHING.  But leaving them takes advantage of experts time and effort.
0
 
aztecs00Author Commented:
thanks mkprasad!  I am really in need.  

jhance, sorry for my "poor behavior".  Let me give you my side of the story... for the grades, well, I ask questions clearly, but then, in the end, the answers I got were just part of the entire solution.  I can't give out an A when I get errors on their suggested solutions, or when I don't get satisfied with the answers I need, right?  However, as some sort of gratitude, I give higher points as a reward.  Now, the unresolved questions are my fault.  I would resolve it immediately.

0
 
ssrCommented:
Another way to get at the answer you seek, is to create a new MFC DLL App Wizard project.  Select File, New, click on the Projects tab, select MFC DLL App Wizard, enter a name, and click Ok.  Then, click Finish, click Ok, and you have a standard MFC DLL project.

SSR
0
 
aztecs00Author Commented:
Now that's an answer!  I did get some errors though, but I could get around it. :)
0
 
mkprasadCommented:
thax aztecs00.
As we work in two diff environment settings,obviously small
errors might be generated like including stdAfx.h,iostream.h with or with out namespace etc!!

i should also say thanks to jhance!
:-)MK
0
All Courses

From novice to tech pro — start learning today.