public static void Main(string[] args) { // Create the MyCar class object. VDServerClassFactory cf = new VDServerClassFactory(); int regID; Guid CLSID_MyObject = new Guid(ABothe.IID.VDServer); UInt32 hResult = COM.CoRegisterClassObject(ref CLSID_MyObject, cf, COM.CLSCTX_LOCAL_SERVER, COM.REGCLS_MULTIPLEUSE | COM.REGCLS_SUSPENDED, out regID); if (hResult != 0) { throw new ApplicationException("CoRegisterClassObject failed" + hResult.ToString("X")); } hResult = COM.CoResumeClassObjects(); if (hResult != 0) { throw new ApplicationException("CoResumeClassObjects failed" + hResult.ToString("X")); } //MessageBox.Show("vdcomserver registered", "[LOCAL] message"); // Now just run until a quit message is sent, // in responce to the final release. //Application.Run(); MSG msg = new MSG(); while (User32.GetMessage(out msg, IntPtr.Zero, 0, 0) != 0) { User32.TranslateMessage(ref msg); User32.DispatchMessage(ref msg); } // All done, so remove class object. COM.CoRevokeClassObject(regID); }
public static void Main(string[] args) { // Create the MyCar class object. VDServerClassFactory cf = new VDServerClassFactory(); int regID; Guid CLSID_MyObject = new Guid(ABothe.IID.VDServer); UInt32 hResult = COM.CoRegisterClassObject(ref CLSID_MyObject, cf, COM.CLSCTX_LOCAL_SERVER, COM.REGCLS_MULTIPLEUSE | COM.REGCLS_SUSPENDED, out regID); if (hResult != 0) throw new ApplicationException("CoRegisterClassObject failed" + hResult.ToString("X")); hResult = COM.CoResumeClassObjects(); if (hResult != 0) throw new ApplicationException("CoResumeClassObjects failed" + hResult.ToString("X")); //MessageBox.Show("vdcomserver registered", "[LOCAL] message"); // Now just run until a quit message is sent, // in responce to the final release. //Application.Run(); MSG msg = new MSG(); while(User32.GetMessage(out msg, IntPtr.Zero, 0, 0) != 0) { User32.TranslateMessage(ref msg); User32.DispatchMessage(ref msg); } // All done, so remove class object. COM.CoRevokeClassObject(regID); }