在程序的我用::CoCreateInstance编译是可以通过的,但用::CoCreateInstanceEx却编译通不过
错误:
:\TestVC\com\Test1\Test1.cpp(42) : error C2039: 'CoCreateInstanceEx' : is not a member of '`global namespace''
D:\TestVC\com\Test1\Test1.cpp(42) : error C2065: 'CoCreateInstanceEx' : undeclared identifier
去掉::也通不过error C2065: 'CoCreateInstanceEx' : undeclared 
郁闷???加objbase.h也是一样

解决方案 »

  1.   

    查MSDN的
    Requirements 
      Windows NT/2000/XP: Requires Windows NT 4.0 or later.
      Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
      Header: Declared in objbase.h.
      Library: Use ole32.lib.
      

  2.   

    to 楼上的 CoCreateInstance怎么不要加,我看在link中,有ole32.lib
      

  3.   

    CoCreateInstanceExRequirements 
    Windows NT/2000/XP: Requires Windows NT 4.0 or later.
    Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
    Header: Declared in objbase.h.
    Library: Use ole32.lib.
      

  4.   

    to  laiyiling(最熟悉的陌生人) :
    CoCreateInstance能用,我用的是win2k_p
      

  5.   

    把debug目录下面的东西都删掉,然后rebuild all看看。
      

  6.   

    TO 楼上的 rebuild all也不行,我什么都删除了也不行,郁闷
    还有请问有没有AnsiToUnicode这样的函数,msdn中居然找不到,书上居然有
      

  7.   

    在程序的最开头定义一句
    #define WINVER 0x0500
    试试
      

  8.   

    那你看看那个H头文件里有没有CoCreateInstanceEx
      

  9.   

    AnsiToUnicode??没见过这样的函数,如果有那转换不是很方便了吗?估计是你书上的自定义函数
      

  10.   

    AnsiToUnicode 是它自己写的一个函数吧。
    用这个MultiByteToWideChar
      

  11.   

    感谢各位,问题已解决
    在stdafx.h中加入#define _WIN32_WINNT 0x0500楼上的加#define WINVER 0x0500不行结帖