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)的更多相关文章

  1. C#:注册组件

    注册flash 为例: 代码比较差 仅供学习参考 /// <summary> /// 注册组件 /// </summary> private static void Regis ...

  2. 从新注册 .DLL CMD 运行regsvr32 *.dll注册该DLL 或 regsvr32 /s *.DLL 求证

    从新注册 .DLL  CMD 运行regsvr32  *.dll注册该DLL  或 regsvr32 /s  *.DLL 求证

  3. Ioc容器Autofac系列(3)-- 三种注册组件的方式

    简单来说,所谓注册组件,就是注册类并映射为接口,然后根据接口获取对应类,Autofac将被注册的类称为组件. 虽然可像上篇提到的一次性注册程序集中所有类,但AutoFac使用最多的还是单个注册.这种注 ...

  4. VueJs(8)---组件(注册组件)

    组件(注册组件) 一.介绍 组件系统是Vue.js其中一个重要的概念,它提供了一种抽象,让我们可以使用独立可复用的小组件来构建大型应用,任意类型的应用界面都可以抽象为一个组件树 那么什么是组件呢? 组 ...

  5. 为什么VUE注册组件命名时不能用大写的?

    这段时间一直在弄vue,当然也遇到很多问题,这里就来跟大家分享一些注册自定义模板组件的心得 首先"VUE注册组件命名时不能用大写"其实这句话是不对的,但我们很多人开始都觉得是对的, ...

  6. 向Spring容器中注册组件的方法汇总小结

    1.通过xml定义 <bean class=""> <property name="" value=""></ ...

  7. Vue 全局注册逐渐 和 局部注册组件

    //定义一个名为 button-counter 的新组件 Script: Vue.component('button-counter',{//button-counter 这个是组件的名字 data: ...

  8. vux 全局注册组件

    背景:调试better-scroll的时候进行封装,作为组件来调用: 希望:全局注册组件: 1,在src的main.js下: 这样就可以用了:

  9. [翻译]Component Registration in Script System 在脚本系统中注册组件

    Component Registration in Script System 在脚本系统中注册组件   To refer to our component from a script, the cl ...

随机推荐

  1. Eclipse中打包maven项目-war包方式

    IntelliJ IDEA打包成war(包括maven项目)点击打开链接 首先要在maven项目中的pom.XML中配置好需要的配置: <project xmlns="http://m ...

  2. java:大小写字母转换

    public class Solution { public static void main(String args[]) { testSolutions.lowercaseToUppercase( ...

  3. A Simple Math Problem HDU1757

    一次ac 在做递推关系的题目的时候  快速幂矩阵真的很有用 #include<iostream> #include<cstdio> #include<cstring> ...

  4. 017 Spark的运行模式(yarn模式)

    1.关于mapreduce on yarn 来提交job的流程 yarn=resourcemanager(RM)+nodemanager(NM) client向RM提交任务 RM向NM分配applic ...

  5. sublime 自定义快捷代码

    选择打开tools ->developer->new snippet <snippet> <content><![CDATA[Hello, ${1:this} ...

  6. POJ 3414 Pot (输出路径)【BFS】

    <题目链接> 题目大意: 有两个容量的空杯子,能够对这两个空杯子进行三种操作: 分别是fill(a),装满a杯子: drop(a),倒空a杯子: pour(a,b),将a杯子中的水倒入b杯 ...

  7. jupyter notebook connecting to kernel problem

    前几天帮同学配置 python 和 anaconda 环境,在装 jupyter notebook 时,出了点问题,搞了一天半终于搞好了,也是在 github 里找到了这个问题的解答. 当时显示的是无 ...

  8. SQLite中的SELECT子句使用别名

    SQLite中的SELECT子句使用别名 开发者可以使用AS关键字为指定的列名提供一个新的别名,其语法形式如下 SELECT column_name AS Alias [,…] 例如,下面的SQL语句 ...

  9. 漫谈可视化Prefuse(五)

    伴随着前期的基础积累,翻过API,读过一些Demo,总觉得自己已经摸透了Prefuse,小打小闹似乎已经无法满足内心膨胀的自己.还记得儿时看的<武状元苏乞儿>中降龙十八掌最后一张居然是空白 ...

  10. Shiro笔记(三)授权

    Shiro笔记(三)授权 一.授权方式 1.编程式: Subject subject=SecurityUtils.getSubject(); if(subject.hasRole("root ...