VC++ Express Edition中缺少afxwin.h文件

Sur*_*j G 26 visual-c++

当我尝试将VC++ 2005文件运行到VC++ 2008时:

1>------ Build started: Project: canvas, Configuration: Debug Win32 ------  
1>Compiling...  
1>canvasApp.cpp  
1>c:\documents and settings\ram\my documents\visual studio 2008\demo\stdafx.h(1) : fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory  
1>canvasFrame.cpp  
1>c:\documents and settings\ram\my documents\visual studio 2008\demo\stdafx.h(1) : fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory  
1>Generating Code...  
1>Build log was saved at "file://c:\Documents and Settings\ram\My Documents\Visual Studio 2008\demo\Debug\BuildLog.htm"  
1>canvas - 2 error(s), 0 warning(s)  
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========  
Run Code Online (Sandbox Code Playgroud)

D H*_*sen 30

发现这篇文章可能有所帮助:http: //social.msdn.microsoft.com/forums/en-US/Vsexpressvc/thread/7c274008-80eb-42a0-a79b-95f5afbf6528/

或者很快,afxwin.h是MFC,MFC不包含在VC++(Express Edition)的免费版本中.

  • 尽管这个答案是谷歌的最佳结果之一,但它已经过时了。自 VS Community 2014 年起,MFC 一直免费。 (2认同)
  • 同意,但根据问题,此答案特定于 Visual Studio 2008。 (2认同)

Mel*_*ius 10

包括标题afxwin.h信号使用MFC.以下说明(基于CodeProject.com上的说明)可以帮助获取MFC代码:

  1. 下载并安装Windows驱动程序工具包.

  2. 选择菜单工具>选项...>项目和解决方案> VC++目录.

  3. 在下拉菜单中显示选择包含文件的目录.

  4. 添加以下路径(替换$(WDK_directory)为第一步中安装Windows Driver Kit的目录):

    $(WDK_directory)\inc\mfc42
    $(WDK_directory)\inc\atl30
    
    Run Code Online (Sandbox Code Playgroud)

  5. 在下拉菜单中显示选择库文件的目录并添加($(WDK_directory)像之前一样替换):

    $(WDK_directory)\lib\mfc\i386
    $(WDK_directory)\lib\atl\i386
    
    Run Code Online (Sandbox Code Playgroud)

  6. $(WDK_directory)\inc\mfc42\afxwin.inl文件中,编辑以下行(从1033开始):

    _AFXWIN_INLINE CMenu::operator==(const CMenu& menu) const
        { return ((HMENU) menu) == m_hMenu; }
    _AFXWIN_INLINE CMenu::operator!=(const CMenu& menu) const
        { return ((HMENU) menu) != m_hMenu; }
    
    Run Code Online (Sandbox Code Playgroud)

    _AFXWIN_INLINE BOOL CMenu::operator==(const CMenu& menu) const
        { return ((HMENU) menu) == m_hMenu; }
    _AFXWIN_INLINE BOOL CMenu::operator!=(const CMenu& menu) const
        { return ((HMENU) menu) != m_hMenu; }
    
    Run Code Online (Sandbox Code Playgroud)

    换句话说,添加BOOL之后_AFXWIN_INLINE.


naX*_*aXa 6

我看到的问题是关于Express Edition,但这个主题很容易在Google搜索中弹出,并且没有其他版本的解决方案.

所以.如果您遇到除Express之外的任何VS版本的此问题,则可以重新运行安装并包含MFC文件.