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 ....
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, ®ID);
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
User contributions licensed under CC BY-SA 3.0