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