+ Reply to Thread
Results 1 to 2 of 2

Thread: COM API returns -2147221008 while creating an ATL object.

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    29

    COM API returns -2147221008 while creating an ATL object.

    I am developing a multi-threading application.

    Below is my code of:
    Code:
    UINT MyThread(LPVOID lpParam)
    {
            ISpellChecker* pSpellChecker = NULL ;
    
    	HRESULT hr = CoCreateInstance(__uuidof(SpellChecker), NULL, CLSCTX_INPROC_SERVER,__uuidof(SpellChecker), (LPVOID *) &pSpellChecker) ;
    
    	if (NULL != pSpellChecker)
    	{
    		//do something...
    	}
    
            return 0 ;
    }
    CoCreateInstance returns "-2147221008" error code.

    What it this error code means and what am I missing?

    Note:
    Code compiles fine.

  2. #2
    It seems that you are missing "CoInitialize(NULL) ;" call.

    In every thready that creates a COM object must call this function.


+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts