Solved

Newbie question!

Posted on 2003-10-23
2
968 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:Nick_72
2 Comments
 
LVL 2

Accepted Solution

by:
eelko earned 100 total points
ID: 9610720
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
0
 
LVL 9

Author Comment

by:Nick_72
ID: 9610855
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?  

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

Title # Comments Views Activity
Add content to output file 4 62
maven archtype selection in eclipse 1 53
has22 challenge 11 80
Detect file exist or not 3 133
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

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

18 Experts available now in Live!

Get 1:1 Help Now