Solved

MFC DLL (Urgent Again)

Posted on 2001-08-27
11
385 Views
Last Modified: 2006-11-17
can anyone post a sample MFC DLL, and an application calling it?  Please post a working sample.  Thanks!
0
Comment
Question by:aztecs00
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 6428213
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
 
LVL 32

Expert Comment

by:jhance
ID: 6428219
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
 
LVL 6

Expert Comment

by:Triskelion
ID: 6428262
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 

Accepted Solution

by:
mkprasad earned 200 total points
ID: 6429093
////// 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
 
LVL 32

Expert Comment

by:jhance
ID: 6429110
mkprasad,

By all means!  Encourage this user's poor behavior!
0
 

Expert Comment

by:mkprasad
ID: 6429227
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
 
LVL 32

Expert Comment

by:jhance
ID: 6429248
>>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
 

Author Comment

by:aztecs00
ID: 6430336
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
 
LVL 2

Expert Comment

by:ssr
ID: 6430667
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
 

Author Comment

by:aztecs00
ID: 6434687
Now that's an answer!  I did get some errors though, but I could get around it. :)
0
 

Expert Comment

by:mkprasad
ID: 6435651
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

861 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