检测插件是否已注册,注册插件

            try
            {
                string str = System.Windows.Forms.Application.StartupPath + @"\ocx\ceshi.ocx";//路径名
                Process p = new Process();
                p.StartInfo.FileName = "regsvr32";
                p.StartInfo.Arguments = str;
                p.StartInfo.Verb = "runas";//管理员权限运行
                p.Start();
                p.WaitForExit();
                p.Close();
            }
            catch (Exception ex)
            {
                string szInfo = ex.Message.ToString(); 
            }

 

        /// <summary>
        /// 检测ocx是否注册
        /// </summary>
        /// <param name="ClassId"></param>
        /// <returns></returns>
        private bool CheckRegistredOcx(string ClassId)
        {
            Microsoft.Win32.RegistryKey Regkey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ClassId);
            if (Regkey != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

 

posted @ 2019-11-21 14:30  ₯㎕~  阅读(137)  评论(0编辑  收藏  举报