Solved

Newbie question!

Posted on 2003-10-23
2
965 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
WinWaitActive parameters 12 31
string initialization in java 11 103
format the code in java 6 72
move a line in eclipse 3 60
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

20 Experts available now in Live!

Get 1:1 Help Now