Click here to Skip to main content
15,923,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: SetWindowLong Pin
Sam Hobbs11-Sep-00 17:50
Sam Hobbs11-Sep-00 17:50 
GeneralRich Edit Question Pin
Mihalcik8-Sep-00 8:25
sussMihalcik8-Sep-00 8:25 
GeneralMDI Child Window Pin
Jamie Nordmeyer8-Sep-00 7:46
Jamie Nordmeyer8-Sep-00 7:46 
GeneralRe: MDI Child Window Pin
Sam Hobbs8-Sep-00 8:34
Sam Hobbs8-Sep-00 8:34 
GeneralRe: MDI Child Window Pin
Jamie Nordmeyer8-Sep-00 8:44
Jamie Nordmeyer8-Sep-00 8:44 
GeneralRe: MDI Child Window Pin
Jamie Nordmeyer8-Sep-00 8:49
Jamie Nordmeyer8-Sep-00 8:49 
GeneralRe: MDI Child Window Pin
Sam Hobbs8-Sep-00 9:01
Sam Hobbs8-Sep-00 9:01 
GeneralDll programming... Linker Error Pin
thedogbear8-Sep-00 5:52
thedogbear8-Sep-00 5:52 
Hello all.

If you're reading this, then you're either very knowledgeable about Dll programming or simply curious.

I'm trying to create my own Extension DLL.

Here's my code:

//MyClass.h
#ifndef _MYCLASS_HEADER_
#define _MYCLASS_HEADER_

class AFX_CLASS_EXPORT CMyClass : public CObject
{
DECLARE_DYNCREATE(CMyClass)

public:
// constructor
CMyClass();
// destructor
~CMyClass();
// some member functions
int getNumber();
void setNumber(int num);


protected:

private:
int m_iNumber;
};

#endif

// MyClass.cpp
#include "stdafx.h"
#include <afxdllx.h>
#include "MyClass.h"

static AFX_EXTENSION_MODULE MyClassDLL = { NULL, NULL };

extern "C" BOOL APIENTRY MyDllMain(HINSTANCE hInstance,DWORD dwReason,LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("MyClass.DLL Initializing!\n");

// Extension DLL one-time initialization
AfxInitExtensionModule(MyClassDLL, hInstance);

// Insert this DLL into the resource chain
new CDynLinkLibrary(MyClassDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("MyClass.DLL Terminating!\n");
AfxTermExtensionModule(MyClassDLL);
}
return TRUE; // ok
}

IMPLEMENT_DYNCREATE(CMyClass, CObject)

// my class member definitions here...

Ok. So that's my code. I want to be able to instanciate the CMyClass class from the resultant Dll.
Unfortunately, when I try to link this into a proper Dll, I get the following error:

mfcs42d.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already defined in MyClass.obj

The entry-point for this Dll is specified as MyDllMain in the Project->Settings->Link->EntryPoint.

What does this error REALLY mean? What do I have to do to make it work?
It's worth noting that I have a sample from a book which is very similar to the above code and it links
to a Dll beautifully. Is there a linker option that needs to be set for my code to link properly?

Thanks for your help!

Regards,
dogBear
GeneralRe: Dll programming... Linker Error Pin
Chris Meech8-Sep-00 8:09
Chris Meech8-Sep-00 8:09 
GeneralCListViewCtrl (ATL) Pin
Chris B.8-Sep-00 5:00
Chris B.8-Sep-00 5:00 
GeneralRe: CListViewCtrl (ATL) Pin
Chris B.8-Sep-00 5:02
Chris B.8-Sep-00 5:02 
Generalsecond SelectObject crashs Pin
real name8-Sep-00 3:45
sussreal name8-Sep-00 3:45 
GeneralRe: second SelectObject crashs Pin
real name21-Sep-00 3:20
sussreal name21-Sep-00 3:20 
GeneralSendKeys Pin
Mustafa Demirhan8-Sep-00 2:07
Mustafa Demirhan8-Sep-00 2:07 
GeneralRe: SendKeys Pin
Remus Lazar8-Sep-00 2:54
Remus Lazar8-Sep-00 2:54 
GeneralRe: SendKeys Pin
Paolo Messina8-Sep-00 8:05
professionalPaolo Messina8-Sep-00 8:05 
GeneralRe: SendKeys Pin
Michael Dunn8-Sep-00 8:11
sitebuilderMichael Dunn8-Sep-00 8:11 
GeneralModeless dialog Pin
Mustafa Demirhan8-Sep-00 2:02
Mustafa Demirhan8-Sep-00 2:02 
GeneralRe: Modeless dialog Pin
Remus Lazar8-Sep-00 2:51
Remus Lazar8-Sep-00 2:51 
GeneralRe: Modeless dialog Pin
Michael Dunn8-Sep-00 8:15
sitebuilderMichael Dunn8-Sep-00 8:15 
GeneralRe: Modeless dialog Pin
Philip Nicoletti8-Sep-00 3:00
Philip Nicoletti8-Sep-00 3:00 
GeneralRe: Modeless dialog Pin
Sam Hobbs8-Sep-00 8:42
Sam Hobbs8-Sep-00 8:42 
GeneralRe: Modeless dialog Pin
Sam Hobbs8-Sep-00 8:49
Sam Hobbs8-Sep-00 8:49 
QuestionHow to catch keyboard and mouse events of all windows? Pin
Mustafa Demirhan8-Sep-00 1:14
Mustafa Demirhan8-Sep-00 1:14 
AnswerRe: How to catch keyboard and mouse events of all windows? Pin
Remus Lazar8-Sep-00 2:59
Remus Lazar8-Sep-00 2:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.