普通注册
string path = System.AppDomain.CurrentDomain.BaseDirectory ;
System.Diagnostics.Process p = System.Diagnostics.Process.Start("regsvr32", path + "DicomObjects.ocx");
管理员注册
private bool RegisterDll(String dllPath)
{
bool result = true;
try
{
if (!File.Exists(dllPath))
{
//Loger.Write(string.Format("“{0}”目录下无“XXX.dll”文件!", AppDomain.CurrentDomain.BaseDirectory));
return false;
}
//拼接命令参数
string startArgs = string.Format("/s \"{0}\"", dllPath);
Process p = new Process();//创建一个新进程,以执行注册动作
p.StartInfo.FileName = "regsvr32";
p.StartInfo.Arguments = startArgs;
//以管理员权限注册dll文件
WindowsIdentity winIdentity = WindowsIdentity.GetCurrent(); //引用命名空间 System.Security.Principal
Wi