Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Newbie question!

Posted on 2003-10-23
2
Medium Priority
?
982 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
eelko earned 400 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

722 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