title: Calling a COM dll from c++, "Class Not Registered"
body: <p>I have created a COM dll in Microsoft Visual Basic 2008. I am trying to call this dll from a C++ project. In the C++ I used "#import U:\path...\MyComDll.tlb" I then used the following code to the DisplayMessage() method.</p>
  
  <pre><code>FB::variant CmdAccessAPI::filePSV(std::string file)
  {
  
  CoInitialize(NULL);
  try
  {
      _MyComClassPtr spIMyComClass;
      HRESULT hr = spIMyComClass.CreateInstance(__uuidof(_MyComClass));
      if (FAILED(hr)) throw _com_error(hr);
  
      spIMyComClass-&gt;DisplayMessage();
  }
      catch (std::exception&amp; e)
  {
      CString strMsg(e.what());
      MessageBox(NULL, strMsg, L"Error", MB_OK);
  }
  catch (_com_error&amp; e)
  {
      CString strMsg;
      strMsg = (TCHAR*) e.Description();
      strMsg += _T("\n");
      strMsg += (TCHAR*) e.ErrorMessage();
      MessageBox(NULL, strMsg, L"COM Error", MB_OK);
  }
  CoUninitialize();
  return "test";
  }
  </code></pre>
  
  <p>When I call this function I get a Class Not Registered error. I have tried to register the dll using regsvr32 and I get the message "MyComDll.dll was loaded, but the DLLREgeisterServer entry point was not found. This file can not be registered."</p>
  
  <p>How do I register the class and get this to work?</p>