locked
No CoCreateInstance in Windows 8 SDK? RRS feed

  • Question

  • I downloaded Visual Studio 2012 and the Windows SDK for Windows 8.  I am trying to write a simple C++ application using CoCreateInstance and can't seem to locate it.  The documentation says it is in Objbase.h and it's not there.  Am I missing something?
    Saturday, August 18, 2012 4:35 PM

Answers

  • The declaration itself is in combaseapi.h, but you don't include that one.  Objbase.h includes that one in line 27.  Therefore, #including Objbase.h will give you CoCreateInstance() as promised.  I just tested this in an empty project (console type) in Visual Studio 2012 Ultimate.  I am getting the function just fine.

    Jose R. MCP
    Code Samples

    • Marked as answer by Eric Haddan Saturday, August 18, 2012 10:10 PM
    Saturday, August 18, 2012 6:15 PM

All replies

  • The declaration itself is in combaseapi.h, but you don't include that one.  Objbase.h includes that one in line 27.  Therefore, #including Objbase.h will give you CoCreateInstance() as promised.  I just tested this in an empty project (console type) in Visual Studio 2012 Ultimate.  I am getting the function just fine.

    Jose R. MCP
    Code Samples

    • Marked as answer by Eric Haddan Saturday, August 18, 2012 10:10 PM
    Saturday, August 18, 2012 6:15 PM
  • Yes, you are correct.  For some reason it was coming up as 'identifier not found', so I temporarily added my own definition.  Now it works when I have removed my own definition.  Really strange.  Thanks for the help.
    Saturday, August 18, 2012 10:13 PM