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
Solved

in ATL #include <afxinet.h> causes  MFC apps must not #include <windows.h> error

Posted on 2000-05-13
5
1,462 Views
Last Modified: 2013-11-25
In an ATL IEHelper project I need to use
CInternetSession session;
and hence to include
<afxinet.h>

but I receive
afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

I already placed the string #include<afxinet.h> in all possible places,  but the error still occured.
Pls advise the workaround.
0
Comment
Question by:rolling_ball
5 Comments
 
LVL 4

Expert Comment

by:AssafLavie
ID: 2807294
Well, it seems that you writing a non-MFC project + trying to use an MFC class.
If you do want to use MFC, you need to switch to an MFC based project. Either start a new one (the easiest way if you project is still pretty small), or make some changes in the project's infrastructure (Like changing the four exported functions and the DLLmain in case of an inproc-server).
0
 

Expert Comment

by:yuxiliu
ID: 2807357
AssafLavie is right
0
 
LVL 2

Accepted Solution

by:
tdubroff earned 50 total points
ID: 2807526
Yes you could restart your project and select the support MFC button, however its not hard to 'hand code' this functionality yourself.  Follow the steps below and you should be on your way:

1) In stdafx.h, just below the line #define STRICT, type in the following:

    // for MFC support
    #include <afxwin.h>
    #include <afxdisp.h>
    // end for MFC

2) In your main .cpp file, where the DllMain() function resides as well as where _Module is defined, type in the following just below the BEGIN_OBJECT_MAP(ObjectMap), END_OBJECT_MAP() macro pair:

    class CYourApp : public CWinApp
    {
    public:
      virtual BOOL InitInstance();
      virtual int ExitInstance();
    };

    CYourApp theApp;

    BOOL CYourApp::InitInstance()
    {
      _Module.Init(ObjectMap, m_hInstance);
      return CWinApp::InitInstance();
    }

    int CYourApp::ExitInstance()
    {
      _Module.Term();
      return CWinApp::ExitInstance();
    }

3) In the same file, comment out the DllMain() function


That should do it.  Hope this helps.

-Ted
0
 

Author Comment

by:rolling_ball
ID: 2809183
Thanks people.
tdubrof - your answer is excellent, I've done all you said and it starts working :)).

Another related question: previously I tryed to make this project support MFC, in project settings I changed to support MFC as shared dll, and saved and restarted project but it was still not supporting MFC.

0
 
LVL 2

Expert Comment

by:tdubroff
ID: 2876483
I found a Microsoft page that explains everything in more detail:
http://support.microsoft.com/support/kb/articles/Q173/9/74.ASP?LN=CAN&SD=gn&FR=0
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Path to  STL Map header file 1 69
Stupid git question 2 101
.php tree directory? 5 83
Animated .jpg? 13 95
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

809 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