public static void RegisterClassInCategory(Guid clsid, Guid catid, string description) { Utils.ICatRegister catRegister = (Utils.ICatRegister)Utils.CreateLocalServer(Utils.CLSID_StdComponentCategoriesMgr); try { string text = null; try { ((Utils.ICatInformation)catRegister).GetCategoryDesc(catid, 0, out text); } catch (Exception innerException) { text = description; if (string.IsNullOrEmpty(text)) { if (catid == Utils.CATID_OPCDAServer20) { text = "OPC Data Access Servers Version 2.0"; } else if (catid == Utils.CATID_OPCDAServer30) { text = "OPC Data Access Servers Version 3.0"; } else if (catid == Utils.CATID_OPCAEServer10) { text = "OPC Alarm & Event Server Version 1.0"; } else { if (!(catid == Utils.CATID_OPCHDAServer10)) { throw new ApplicationException("No description for category available", innerException); } text = "OPC History Data Access Servers Version 1.0"; } } Utils.CATEGORYINFO categoryinfo; categoryinfo.catid = catid; categoryinfo.lcid = 0; categoryinfo.szDescription = text; catRegister.RegisterCategories(1, new Utils.CATEGORYINFO[] { categoryinfo }); } catRegister.RegisterClassImplCategories(clsid, 1, new Guid[] { catid }); } finally { Utils.ReleaseServer(catRegister); } }
public static void UnregisterClassInCategory(Guid clsid, Guid catid) { Utils.ICatRegister catRegister = (Utils.ICatRegister)Utils.CreateLocalServer(Utils.CLSID_StdComponentCategoriesMgr); try { catRegister.UnRegisterClassImplCategories(clsid, 1, new Guid[] { catid }); } finally { Utils.ReleaseServer(catRegister); } }