public static uint Register(ComServer server) { var clsid = new Guid(IpcClientServer.ClassId); var result = (uint)COMNative.S_OK; var hResult = COMNative.CoRegisterClassObject(ref clsid, new IpcClientServerClassFactory(server), CLSCTX.LOCAL_SERVER, REGCLS.MULTIPLEUSE | REGCLS.SUSPENDED, out result); if (hResult != COMNative.S_OK) { throw new ApplicationException("CoRegisterClassObject failed w/err 0x" + hResult.ToString("X")); } hResult = COMNative.CoResumeClassObjects(); if (hResult != COMNative.S_OK) { if (result != COMNative.S_OK) { COMNative.CoRevokeClassObject(result); } throw new ApplicationException("CoResumeClassObjects failed w/err 0x" + hResult.ToString("X")); } return(result); }
public IpcClientServerClassFactory(ComServer server) { this.server = server; }