Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public static void Unregister(uint cookie)
 {
     if (cookie != 0)
     {
         COMNative.CoRevokeClassObject(cookie);
     }
 }