现在的位置: 首页 > 综合 > 正文

CoInitializeEx编译通过的问题

2012年12月31日 ⁄ 综合 ⁄ 共 638字 ⁄ 字号 评论关闭

在初始化Com套间的时候,调用CoInitializeEx(NULL, COINIT_MULTITHREADED); 可编译器总是提示编译:

 error C2065: 'CoInitializeEx' : undeclared identifier

error C2065: 'COINIT_MULTITHREADED' : undeclared identifier

最后,在stdafx.h文件中的增加红色代码就可以了。

......

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400           //使用CoInitializeEx
#endif

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxcview.h>
#include <afxdisp.h>        // MFC Automation classes
#include <afxdtctl.h>  // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>   // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

......

抱歉!评论已关闭.