예제 #1
0
        //证书吊销状态检查等注册表项更改


        public static void SetWinTrust()
        {
            object uncheckPublisherTag = "146944";

            //不检查发行商的证书吊销状态,这样可以增加VSTO ADD IN 加载及运行速度
            try
            {
                var reg = new RegisterHelper(WinTrustRegistryKey, RegisterHelper.RegDomain.CurrentUser);
                reg.WriteRegeditKey(StateSubKey, uncheckPublisherTag);
            }
            catch (Exception e)
            {
                //不处理
                Log.Debug(e);
            }
        }
예제 #2
0
 private static bool SetAddinReg(string path, bool bClear)
 {
     try
     {
         Log.Debug("SetAddinReg---Begin");
         // 检查路径是否为空
         if (string.IsNullOrEmpty(path))
         {
             return(false);
         }
         var domain = RegisterHelper.RegDomain.CurrentUser;
         //if (!IsNeedRunAsAdmin())
         //{
         //    domain = RegisterHelper.RegDomain.LocalMachine;
         //}
         var dir = new DirectoryInfo(path);
         if (!dir.Exists)
         {
             return(false);
         }
         path = path.Replace('/', '\\');
         if (path.EndsWith("\\"))
         {
             path = path.Remove(path.Length - 1, 1);
         }
         string addinPath = @"#Path#\Bin\Cooperativeness.OBA.Word.Addins.vsto|vstolocal";
         addinPath = addinPath.Replace("#Path#", path);
         Log.Debug("addinReg---addinPath:" + addinPath);
         // 清理卸载插件的注册表
         var reg = new RegisterHelper(RegCooperativenessAddins, domain);
         reg.CreateSubKey();
         Log.Debug("addinReg----CreateSubKey");
         string[] name  = { "Description", "FriendlyName", "LoadBehavior", "Manifest" };
         string[] value = { "Cooperativeness.OBA.Word.Addins V2.0", "协同文档工具", "00000003", addinPath };
         for (int i = 0; i < 4; i++)
         {
             if (reg.IsRegeditKeyExist(name[i]))
             {
                 reg.DeleteRegeditKey(name[i]);
                 Log.Debug("addinReg----DeleteRegeditKey----name:" + name[i]);
             }
             if (!bClear)
             {
                 if (name[i].Equals("LoadBehavior", StringComparison.InvariantCultureIgnoreCase))
                 {
                     reg.WriteRegeditKey(name[i], value[i], RegisterHelper.RegValueKind.DWord);
                     Log.Debug("addinReg----WriteRegeditKey----name:" + name[i]);
                 }
                 else
                 {
                     reg.WriteRegeditKey(name[i], value[i], RegisterHelper.RegValueKind.String);
                     Log.Debug("addinReg----WriteRegeditKey----name:" + name[i]);
                 }
             }
         }
         if (bClear)
         {
             reg.DeleteSubKey();
         }
         return(true);
     }
     catch (Exception e)
     {
         Log.Debug(e);
         return(false);
     }
 }
예제 #3
0
 private static bool SetVstoReg(string path, bool bClear)
 {
     try
     {
         // 检查路径是否为空
         if (string.IsNullOrEmpty(path))
         {
             return(false);
         }
         var domain = RegisterHelper.RegDomain.CurrentUser;
         //if (!IsNeedRunAsAdmin())
         //{
         //    domain = RegisterHelper.RegDomain.LocalMachine;
         //}
         var dir = new DirectoryInfo(path);
         if (!dir.Exists)
         {
             return(false);
         }
         path = path.Replace("\\", "/");
         if (path.EndsWith("/"))
         {
             path = path.Remove(path.Length - 1, 1);
         }
         string addinPath = @"file://#UrlPath#/Bin/Cooperativeness.OBA.Word.Addins.vsto";
         addinPath = addinPath.Replace("#UrlPath#", path);
         Log.Debug("SetVstoReg---addinPath:" + addinPath);
         // 清理卸载插件的注册表
         var reg = new RegisterHelper(RegAddinsRsakey, domain);
         if (!reg.IsSubKeyExist())
         {
             reg.CreateSubKey();
         }
         Log.Debug("SetVstoReg----CreateSubKey");
         string[] name  = { "Url", "PublicKey" };
         string[] value = { addinPath, "<RSAKeyValue><Modulus>8Z2Xak1KQWtPxWNvUeAIDi4N8jvlOnCdhvdvZ4CU0HruSqF7LK1+bi89slJuiQ5dsn7y2nbMB8hIV8HXmXEgn6U+wu6Pqcl6uleuzoYbRbTHLbjkoTDTyy6XeDynno9W6vCcKD8CrrKv08Jc60LFgHcqlLwqm6UegL1Uu9IGQmU=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>" };
         for (int i = 0; i < 2; i++)
         {
             if (reg.IsRegeditKeyExist(name[i]))
             {
                 reg.DeleteRegeditKey(name[i]);
                 Log.Debug("SetVstoReg----DeleteRegeditKey---name:" + name[i]);
             }
             if (!bClear)
             {
                 reg.WriteRegeditKey(name[i], value[i], RegisterHelper.RegValueKind.String);
                 Log.Debug("SetVstoReg----WriteRegeditKey---name:" + name[i]);
             }
         }
         if (bClear)
         {
             reg.DeleteSubKey();
         }
         return(true);
     }
     catch (Exception e)
     {
         Log.Debug(e);
         return(false);
     }
 }