VS2008 新建的win32 DLL 工程,加了一个文件引用CAsyncSocket类后,编译总提示fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>。
以前是编译成功通过的,而且DLL也是可以运行的,后来不知道改动了什么东西,老是出现这个提示,现将整个工程上传。成功解决的加分+100元手机话费酬谢工程下载 http://download.csdn.net/detail/yhgfriend/6475189
重点在UDP.cpp文件

解决方案 »

  1.   

    CAsyncSocket是MFC类,那你最好是应该新建MFC DLL工程
      

  2.   

    要么就用winsock API去写,不要使用CAsyncSocket类
      

  3.   

    以下为UDP.CPP的开始部分****************************************************
    #include "stdafx.h"
    #include <stdio.h>
    #include "MySocket.h"
    #include <winsock2.h>#pragma comment(lib, "ws2_32.lib")
    *********************************************************************
    以下为MySocket.h文件全部*********************************************#include <Afxsock.h>
    #if !defined(AFX_MYSOCKET_H__6113F2E0_C873_43EB_BFF1_14FF81B6AF9F__INCLUDED_)
    #define AFX_MYSOCKET_H__6113F2E0_C873_43EB_BFF1_14FF81B6AF9F__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    // MySocket.h : header file
    ///////////////////////////////////////////////////////////////////////////////
    // MySocket command targetclass MySocket : public CAsyncSocket
    {
    // Attributes
    public:// Operations
    public:
    MySocket();
    virtual ~MySocket();// Overrides
    public:
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(MySocket)
    public:
    virtual void OnAccept(int nErrorCode);
    virtual void OnReceive(int nErrorCode);
    //}}AFX_VIRTUAL // Generated message map functions
    //{{AFX_MSG(MySocket)
    // NOTE - the ClassWizard will add and remove member functions here.
    //}}AFX_MSG// Implementation
    protected:
    };///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MYSOCKET_H__6113F2E0_C873_43EB_BFF1_14FF81B6AF9F__INCLUDED_)
      

  4.   

    问题解决了,那本来就是个错误的工程,我一直以为以前能正常使用并且生成DLL的就是那个工程,后来分析源文件及功能才发现不是我要的版本。在另一个文件夹下面找到了能正常使用的项目了。结贴。