C#:注册组件 (cmd)
public class ComRegistor
{
public static string classID = "CLSID\\{479A1AAC-C148-40BB-9868-A9773DA66AF9}\\";//SWFToImage组件注册ID /// <summary>
/// 注册组件
/// </summary>
/// <param name="fileFullName">文件完整路径</param>
/// <param name="dllName">动态库名</param>
public static bool Register(string fileFullName, string dllName)
{
bool rev = false;
try
{
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 = false;
p.Start();
p.StandardInput.WriteLine(@"DELETE " + fileFullName + @" %windir%\system32");
p.StandardInput.WriteLine(@"COPY " + fileFullName + @" %windir%\system32");
p.StandardInput.WriteLine(@"regsvr32 /s %windir%\system32\" + dllName);
p.StandardInput.WriteLine("exit");
string ReturnInfo = p.StandardOutput.ReadToEnd();
p.Close();
rev = true;
}
catch (Exception e)
{
rev = false;
} return rev;
}
/// <summary>
/// 判别某一组件是否已注册
/// </summary>
/// <returns></returns>
public static bool IsRegister(string classID)
{
bool result = false;
RegistryKey rkTest = Registry.ClassesRoot.OpenSubKey(classID);
if (rkTest != null)
{
result = true;
}
return result;
} /* if (!ComRegistor.IsRegister(ComRegistor.classID))
{
if (File.Exists(System.Environment.SystemDirectory + Path.DirectorySeparatorChar + "SWFToImage.DLL") == true)
{
File.Delete(System.Environment.SystemDirectory + Path.DirectorySeparatorChar + "SWFToImage.DLL");
} ComRegistor.Register(Application.StartupPath + @"\RegSvr\SWFToImage.Dll", "SWFToImage.Dll"); if (!ComRegistor.IsRegister(ComRegistor.classID))
MessageBox.Show("COM组件注册失败");
}
*/
}
C#:注册组件 (cmd)的更多相关文章
- C#:注册组件
注册flash 为例: 代码比较差 仅供学习参考 /// <summary> /// 注册组件 /// </summary> private static void Regis ...
- 从新注册 .DLL CMD 运行regsvr32 *.dll注册该DLL 或 regsvr32 /s *.DLL 求证
从新注册 .DLL CMD 运行regsvr32 *.dll注册该DLL 或 regsvr32 /s *.DLL 求证
- Ioc容器Autofac系列(3)-- 三种注册组件的方式
简单来说,所谓注册组件,就是注册类并映射为接口,然后根据接口获取对应类,Autofac将被注册的类称为组件. 虽然可像上篇提到的一次性注册程序集中所有类,但AutoFac使用最多的还是单个注册.这种注 ...
- VueJs(8)---组件(注册组件)
组件(注册组件) 一.介绍 组件系统是Vue.js其中一个重要的概念,它提供了一种抽象,让我们可以使用独立可复用的小组件来构建大型应用,任意类型的应用界面都可以抽象为一个组件树 那么什么是组件呢? 组 ...
- 为什么VUE注册组件命名时不能用大写的?
这段时间一直在弄vue,当然也遇到很多问题,这里就来跟大家分享一些注册自定义模板组件的心得 首先"VUE注册组件命名时不能用大写"其实这句话是不对的,但我们很多人开始都觉得是对的, ...
- 向Spring容器中注册组件的方法汇总小结
1.通过xml定义 <bean class=""> <property name="" value=""></ ...
- Vue 全局注册逐渐 和 局部注册组件
//定义一个名为 button-counter 的新组件 Script: Vue.component('button-counter',{//button-counter 这个是组件的名字 data: ...
- vux 全局注册组件
背景:调试better-scroll的时候进行封装,作为组件来调用: 希望:全局注册组件: 1,在src的main.js下: 这样就可以用了:
- [翻译]Component Registration in Script System 在脚本系统中注册组件
Component Registration in Script System 在脚本系统中注册组件 To refer to our component from a script, the cl ...
随机推荐
- 乐观锁和悲观锁及CAS实现
乐观锁与悲观锁 悲观锁:总是假设最坏的情况,每次去拿数据的时候都认为别人会修改,所以每次在拿数据的时候都会上锁,这样别人想拿这个数据就会阻塞直到它拿到锁.传统的关系型数据库里边就用到了很多这种锁机制, ...
- python学习之集合
集合(set)是一个无序的不重复元素序列. 可以使用大括号 { } 或者 set() 函数创建集合,注意:创建一个空集合必须用 set() 而不是 { },因为 { } 是用来创建一个空字典. 创建格 ...
- 023 SpringMVC拦截器
一:拦截器的HelloWorld 1.首先自定义拦截器 只要实现接口就行. package com.spring.it.interceptors; import javax.servlet.http. ...
- 003 将spark源码导入到IDEA中
1.解压源代码 2.进入IDEA的首界面 3.使用open将解压的工程加载 4.将文件的形式改成maven项目 5.使用
- 《Gradle权威指南》--Groovy基础
No1: Groovy中分号不是必须的 No2: Groovy中,单引号和双引号都可以定义一个字符串常量,不同的是单引号标记的是纯粹的字符串常量,而不是对字符串里的表达式做运算,但是双引号可以. ta ...
- POJ 2337 Catenyms(有向欧拉图:输出欧拉路径)
题目链接>>>>>> 题目大意: 给出一些字符串,问能否将这些字符串 按照 词语接龙,首尾相接 的规则 使得每个字符串出现一次 如果可以 按字典序输出这个字符串 ...
- JS-最全的创建对象的方式
JS最全创建对象方式汇总 1.最简单的方式--创建一个Object实例 var person = new Object(); //创建实例 person.name = "BlueBeginn ...
- IE8 margin:0 auto 不能居中显示的问题
ie8下面margin:0 auto;不能居中的解决方案,ie8兼容性代码 今天写了个div,用margin:0 auto:来定义他的属性,让他居中,结果,竟然无效. 一开始以为是css里的代码冲突了 ...
- Codeforces Round #513 游记
Codeforces Round #513 游记 A - Phone Numbers 题目大意: 电话号码是8开头的\(1\)位数字.告诉你\(n(n\le100)\)个数字,每个数字至多使用一次.问 ...
- [CodeVS4633][Mz]树链剖分练习
思路: 轻重链剖分+线段树. #include<cstdio> #include<vector> #include<cstring> ; std::vector&l ...