error C2065: 'CoInitializeEx' : undeclared identifier; 解决方法

在stdafx.h中定义(放在#define VC_EXTRALEAN 的下一行)
#define _WIN32_WINNT 0x0500

实际上你可以看objbase.h的文件中CoInitializeEx的定义:

#if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
WINOLEAPI CoInitializeEx(LPVOID pvReserved, DWORD dwCoInit);
#endif // DCOM

**************************************************************

Header: Declared in objbase.h.
Library: Use ole32.lib.

另外,别忘了定义_WIN32_DCOM

 

http://www.cppblog.com/microli/articles/11916.html

你可能感兴趣的:(c,header)