示例#1
0
        private static void RemoveDemandLoadingEntries(bool currentUser)
        {
            try
            {
                // Choose a Registry hive based on the function input

                RegistryKey hive =
                    (currentUser ?
                     Registry.CurrentUser :
                     Registry.LocalMachine);

                // Open the main AutoCAD (vertical) and "Applications" keys
                //RegistryKey ack = hive.OpenSubKey(HostApplicationServices.Current.RegistryProductRootKey);
                RegistryKey ack = hive.OpenSubKey(HostApplicationServices.Current.UserRegistryProductRootKey);

                using (ack)
                {
                    RegistryKey appk = ack.OpenSubKey("Applications", true);
                    using (appk)
                    {
                        // Delete the key with the same name as this assembly

                        appk.DeleteSubKeyTree(
                            Assembly.GetExecutingAssembly().GetName().Name
                            );
                    }
                }
            }
            catch { }
        }
示例#2
0
        private static void UninstallRegedit(string appPath)
        {
            Document dwg  = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor   aced = dwg.Editor;

            aced.WriteMessage("\n 开始删除AutoCAD CMCU插件注册表:");
            try
            {
                Autodesk.AutoCAD.Runtime.RegistryKey LocalMachine = Autodesk.AutoCAD.Runtime.Registry.LocalMachine;
                Autodesk.AutoCAD.Runtime.RegistryKey Applications = LocalMachine.OpenSubKey(appPath, true);
                string[] subKeys = Applications.GetSubKeyNames();
                if (subKeys.Contains(CommonVariable.regeditSubKeyName))
                {
                    Applications.DeleteSubKeyTree(CommonVariable.regeditSubKeyName);
                }
                aced.WriteMessage("\n 删除AutoCAD CMCU插件注册表成功");
            }
            catch (System.Exception ex)
            {
                aced.WriteMessage("\n 删除AutoCAD CMCU插件注册表失败!");
                aced.WriteMessage("\n{0}", ex.ToString());
            }
        }