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

            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;
            }
        }

猜你喜欢

转载自www.cnblogs.com/yc1224/p/11905459.html