Win32 COM Interface Registration Erros

-1

I'm having trouble trying to get this program to work at the following link.

https://www.codeproject.com/Articles/8679/Building-a-LOCAL-COM-Server-and-Client-A-Step-by-S

It's possible to get it build and running by upgrading the solution and using iostream as well as a using namespace std statement.

Sadly the program fails at runtime. Error code REGDB_E_IIDNOTREG Interface not registered.

I've tried a few things and the furthest I've gotten is:

WinRT originate error - 0x80040155 : 'Failed to find proxy registration for IID: {43ad32 ....

  • What Can I do to get this to work?
  • Why would a failed to find proxy registration occur and what can be done to fix it?
  • What is windows trying to do and what is it looking for when I call CreateInstance that causes these failers?
  • Is there any good material out there that I can use to learn more about this stuff?

Here's the client code:

cout << endl << "Get the class factory interface for the Car class...";
hr = CoGetClassObject(CLSID_MyCar,CLSCTX_LOCAL_SERVER,NULL,IID_IClassFactory,(void**)&pICF);
if ( FAILED(hr) )
{
    ShowErrorMessage("CoGetClassObject()",hr);
    exit(1);
}
else cout << "success." << endl;

cout << "Create the Car object and get back the ICreateMyCar interface...";
hr = pICF->CreateInstance(NULL,IID_ICreateMyCar,(void**)&pICreateMyCar);
if ( FAILED(hr) )
{
    ShowErrorMessage("CoGetClassObject()",hr);
    exit(1);
}
else cout << "success." << endl;

Here's the server code:

    MyCarClassFactory myCarClassFactory;

    // Register the MyCar Factory.
    DWORD regID = 0;
    hr = CoRegisterClassObject(CLSID_MyCar, (IClassFactory*)&myCarClassFactory, 
                               CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &regID);
    if ( FAILED(hr) )
    {
        ShowErrorMessage("CoRegisterClassObject()",hr);
        CoUninitialize();
        exit(1);
    }

The .idl:

// library statement
[uuid(957BF83F-EE5A-42eb-8CE5-6267011F0EF9), version(1.0),
 helpstring("Car server with typeLib")]
library CarLocalServerLib
{
   importlib("stdole32.tlb");
   [uuid(1D66CBA8-CCE2-4439-8596-82B47AA44E43)]
   coclass MyCar
   {
      [default] interface ICreateMyCar;
      interface IStats;
      interface IEngine;
   };
};



REGEDIT
HKEY_CLASSES_ROOT\Liyang.CarLocalServer.MyCar\CLSID = {1D66CBA8-CCE2-4439-8596-82B47AA44E43}
HKEY_CLASSES_ROOT\CLSID\{1D66CBA8-CCE2-4439-8596-82B47AA44E43} = Liyang.CarLocalServer.MyCar
HKEY_CLASSES_ROOT\CLSID\{1D66CBA8-CCE2-4439-8596-82B47AA44E43}\LocalServer32 = D:\Desktop\CarLocalServer\Debug\CarLocalServer.exe
c++
winapi
com
asked on Stack Overflow Nov 17, 2020 by SoundScape • edited Nov 17, 2020 by Acorn

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0