★★★程序中注册ocx控件有没有好的方法★★★
一种方法如下:
//----------------------------------
System.Diagnostics.Process.Start(@ "regsvr32.exe ", "/s c:\\Flash.ocx ");
我不加/s 会在程序中弹出对话框,我加对话框消失,但我怎么也捕获不到错误信息,就算注册失败,我的程序也捕获不到
还有一种方法
//-----------------------------------
RegistrationServices abc = new RegistrationServices();
Assembly a;
try{
a = Assembly.Load(@ "c:\CreateUUID.ocx ");
abc.RegisterAssembly(a, AssemblyRegistrationFlags.None);
}
catch (Exception E){
OP_Log.WirteLogEx( "注册组件失败,错误为 < " + E.Message + "> ");
}
这种方法忘了从哪找的了,但a = Assembly.Load(@ "c:\CreateUUID.ocx ");老加载不成功。
//----------------------------------------
各位大侠,谁能给点提示,我怎么才能比较好的注册ocx待ActiveX组件
------解决方案--------------------直接使用程序运行 cmd命令运行注册命令,可带参数
------解决方案--------------------接分就是真支持
------解决方案--------------------在命令行里运行注册命令进行注册就好了吧。 主要注册一次就好了
------解决方案--------------------Process p=new Process();
p.StartInfo.FileName= "cmd.exe ";
p.StartInfo.UseShellExecute=false;
p.StartInfo.RedirectStandardInput=true;
p.StartInfo.RedirectStandardOutput=true;
p.StartInfo.RedirectStandardError=true;
p.StartInfo.CreateNoWindow=true;
p.Start();
p.StandardInput.WriteLine( "regsvr32 "+参数);
p.StandardInput.WriteLine( "exit ");
string resuilt=p.StandardOutput.ReadToEnd();
可以分析此resuilt判断是否注册成功!