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

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

 

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

 

你可能感兴趣的:(检测插件是否已注册,注册插件)