Newbie question!

Nick_72
Nick_72 used Ask the Experts™
on
I'm trying to write a dll, but I didn't get far until I ran into an annyoing problem.
I want to use the CCriticalSection class, and according to the msdn I have to include
afxmt.h. However, that gives me the following error:

fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

I tried to place afxmt.h over stdafx.h, and that gave another error (or errors):

error C2065: 'CCriticalSection' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'ccs'
error C2065: 'ccs' : undeclared identifier

What is going on?? I've pasted the code below.


#include "stdafx.h"
#include "afxmt.h"


BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                               )
{
    CCriticalSection ccs;
      
    return TRUE;
}

Thanks in advance.

/Nick
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
I think the problem is that you should add MFC support when you create your project.
So choose MFC Appwizard (dll) project instead of a Win32 Dynamic-Link Library

Author

Commented:
Ok, that worked better, thanks :)

I used the third option: MFC extension DLL (Using Shared MFC DLL), not knowing really why.  What is the main difference between the three of them?  

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial