基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
/***********************
|
||||
* 说明:注册控件通用类
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2018-05-08
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
***********************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Microsoft.Win32;
|
||||
using System.Diagnostics;
|
||||
using System.Security.AccessControl;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.Util
|
||||
{
|
||||
/// <summary>
|
||||
/// Class RegControlHelper.
|
||||
/// </summary>
|
||||
public class RegControlHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>说明:进行注册</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-29 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public static bool Registe(string regisFile)
|
||||
{
|
||||
bool result = false;
|
||||
System.Diagnostics.Process p = new Process();
|
||||
p.StartInfo.FileName = "Regsvr32.exe";
|
||||
p.StartInfo.Arguments = regisFile+" /s";//路径中不能有空格
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
p.StartInfo.Verb = "runas";
|
||||
p.Start();
|
||||
if (p != null && p.HasExited)
|
||||
{
|
||||
Int32 exitCode = p.ExitCode;
|
||||
if (exitCode == 0)
|
||||
result = true;
|
||||
}
|
||||
p.Close();
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:判断注册表是否注册</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-05-09 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public static bool IsRegistered(string RegisterId)
|
||||
{
|
||||
if (String.IsNullOrEmpty(RegisterId))
|
||||
return false;
|
||||
String key = String.Format(@"CLSID\{{{0}}}", RegisterId);
|
||||
RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(key);
|
||||
return regKey == null ? false : true;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:注册OCX</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-07-31 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if [is register cm capture]; otherwise, <c>false</c>.</returns>
|
||||
public static void IsRegisterOcx(string fileName)
|
||||
{
|
||||
Process proc = null;
|
||||
try
|
||||
{
|
||||
//获取文件信息
|
||||
FileInfo fileInfo = new FileInfo(fileName);
|
||||
//重新设置该文件的管理员完全控制访问权限
|
||||
System.Security.AccessControl.FileSecurity fileSecurity = fileInfo.GetAccessControl();
|
||||
fileSecurity.ResetAccessRule(new FileSystemAccessRule("Administrators", FileSystemRights.FullControl, AccessControlType.Allow));
|
||||
fileInfo.SetAccessControl(fileSecurity);
|
||||
proc = new Process();
|
||||
proc.StartInfo.UseShellExecute = false;
|
||||
proc.StartInfo.CreateNoWindow = true;
|
||||
proc.StartInfo.FileName = fileName;
|
||||
proc.StartInfo.Arguments = string.Format("10");//this is argument
|
||||
proc.StartInfo.CreateNoWindow = false;
|
||||
proc.StartInfo.Verb = "runas";
|
||||
proc.Start();
|
||||
proc.WaitForExit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user