110,538
社区成员
发帖
与我相关
我的任务
分享
for (int i = 0; i < list.Count; i++)
{
string num = list[i].ToString();//文件路径
int a = num.LastIndexOf(".");
string suffix = num.Substring(a + 1);//文件后缀名
if(suffix=="dll")
{
string commd = "regsvr32 \"" + num+"\"";
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";//设定程序名
p.StartInfo.Arguments = "";
p.StartInfo.UseShellExecute = false;//关闭Shell的使用
p.StartInfo.RedirectStandardInput = true;//重定向标准输入
p.StartInfo.RedirectStandardOutput = true;//重定向标准输出
p.StartInfo.RedirectStandardError = true;//重定向错误输出
p.StartInfo.CreateNoWindow = false;//设置不显示窗口
p.Start();//启动
p.StandardInput.WriteLine(commd);//参数为DOS命令
p.StandardInput.WriteLine("exit");
dll++;
}
[DllImport(@"C:\Users\wh\Desktop\啊啊\ECCartoExtension.dll")]
public static extern int DllRegisterServer();
int ah = DllRegisterServer();
if (ah >= 0)
{
//注册成功!
}
else
{
//注册失败
}
string commd = "regsvr32 \"" + num+"\"";
Process p = new Process();
p.StartInfo.FileName = "regsvr32.exe";//设定程序名
p.StartInfo.Arguments = "/s C:\\Users\\dview\\Desktop\\zhuc\\插件2\\GPSubPoints.dll";
p.StartInfo.UseShellExecute = false;//关闭Shell的使用
p.StartInfo.RedirectStandardInput = false;//重定向标准输入
p.StartInfo.RedirectStandardOutput = false;//重定向标准输出
p.StartInfo.RedirectStandardError = false//重定向错误输出
p.StartInfo.CreateNoWindow = false;//设置不显示窗口
int n;
p.Start();//启动
p.WaitForExit();//等待管理进程退出(DOS)
int pExit = -1;
if (p.HasExited)
{
pExit = p.ExitCode;//==0成功,否则失败
if (pExit == 0)
{
MessageBox.Show("注册成功");
}
}
再试试?regsvr32 /s C:\Users\wh\Desktop\ECCartoExtension.dll
if errorlevel 1 echo ERROR!&goto :EOF
echo OK.
试试看。if(suffix=="dll")
{
string commd = "regsvr32 \"" + num+"\"";
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";//设定程序名
p.StartInfo.Arguments = "";
p.StartInfo.UseShellExecute = false;//关闭Shell的使用
p.StartInfo.RedirectStandardInput = true;//重定向标准输入
p.StartInfo.RedirectStandardOutput = true;//重定向标准输出
p.StartInfo.RedirectStandardError = true;//重定向错误输出
p.StartInfo.CreateNoWindow = false;//设置不显示窗口
int n;
p.Start();//启动
p.StandardInput.WriteLine(@"regsvr32 /s C:\Users\dview\Desktop\zhuc\插件2\GPSubPoints.dll");
n = p.Id;
p.StandardInput.WriteLine("exit");//退出DOS,注释后DOS窗体需要手动关闭
p.WaitForExit();//等待管理进程退出(DOS)
int pExit = -1;
if (p.HasExited)
{
pExit = p.ExitCode;//proEC==0成功,否则失败
if (pExit == 0)
{
MessageBox.Show("注册成功");
}
}
//p.StandardInput.WriteLine(commd);//参数为DOS命令
dll++;
}
else if (suffix == "ttf")
Dim procID As Integer
Dim newProc As Diagnostics.Process
newProc = Diagnostics.Process.Start("regsvr32 /s C:\\Users\\wh\\Desktop\\ECCartoExtension.dll")
procID = newProc.Id
newProc.WaitForExit()
Dim procEC As Integer = -1
If newProc.HasExited Then
procEC = newProc.ExitCode //procEC==0成功,否则失败
End If
Dim procID As Integer
Dim newProc As Diagnostics.Process
newProc = Diagnostics.Process.Start("CMD /c a.bat >out.txt")
procID = newProc.Id
newProc.WaitForExit()
Dim procEC As Integer = -1
If newProc.HasExited Then
procEC = newProc.ExitCode
End If
//读文件out.txt的内容