Thanks to @HansPassant, here are the registry keys and values required for serving a single class with a single interface from a C# Windows Service called MyService
:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\TypeLib\{TlbGuid}]
@=""
[HKEY_CLASSES_ROOT\TypeLib\{TlbGuid}\1.0]
@="MyService"
[HKEY_CLASSES_ROOT\TypeLib\{TlbGuid}\1.0\0]
[HKEY_CLASSES_ROOT\TypeLib\{TlbGuid}\1.0\0\win64]
@="C:\\path\\to\\MyService.tlb"
[HKEY_CLASSES_ROOT\TypeLib\{TlbGuid}\1.0\FLAGS]
@="0"
[HKEY_CLASSES_ROOT\Interface\{InterfaceGuid}]
@="IMyInterface"
[HKEY_CLASSES_ROOT\Interface\{InterfaceGuid}\ProxyStubClsid32]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_CLASSES_ROOT\Interface\{InterfaceGuid}\TypeLib]
@="{TlbGuid}"
"Version"="1.0"
[HKEY_CLASSES_ROOT\CLSID\{ClassGuid}]
@="My class name"
"AppID"="{AppIdOrGuid}"
[HKEY_CLASSES_ROOT\CLSID\{ClassGuid}\Version]
@="1.0"
[HKEY_CLASSES_ROOT\AppID\{AppIdOrGuid}]
"LocalService"="MyService"
Then the implementation is easy on the c++ side:
#import "C:\path\to\MyService.tlb"
...
IMyInterfacePtr ptr(__uuidof(MyImplementingClass));
ptr->CallSomeFunction();
...