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. asp.net core 微信获取用户openid

    获取openid流程为首先根据微信开发参数构造AuthorizeUrl认证链接,用户跳转到该链接进行授权,授权完成将跳转到回调页(首次认证需要授权,后面将直接再跳转至回调页),此时回调页中带上一个GE ...

  2. Codeforces 269C Flawed Flow (看题解)

    我好菜啊啊啊.. 循环以下操作 1.从队列中取出一个顶点, 把哪些没有用过的边全部用当前方向. 2.看有没有点的入度和 == 出度和, 如果有将当前的点加入队列. 现在有一个问题就是, 有没有可能队列 ...

  3. 7.Django|分页器

    Django的分页器paginator 文件为pageDemo models.py from django.db import models # Create your models here. cl ...

  4. canvas三角函数模拟水波效果

    .katex { display: block; text-align: center; white-space: nowrap; } .katex-display > .katex > ...

  5. iOS11开发教程(二十三)iOS11应用视图实现按钮的响应(3)

    iOS11开发教程(二十三)iOS11应用视图实现按钮的响应(3) 2.使用代码添加按钮实现的响应 使用代码添加的按钮,实现响应需要使用到addTarget(_:action:for:)方法,其语法形 ...

  6. JS-排序详解-快速排序

    说明 时间复杂度指的是一个算法执行所耗费的时间 空间复杂度指运行完一个程序所需内存的大小 稳定指,如果a=b,a在b的前面,排序后a仍然在b的前面 不稳定指,如果a=b,a在b的前面,排序后可能会交换 ...

  7. YUI Compressor JS和CSS压缩工具使用方式(使用前安装JDK)

    压缩测试: 选中 test.js, 执行右键菜单“Process with &YUICompressor”,会生成 test-min.js. 注意事项: 1. 需要安装 JDK >= 1 ...

  8. POJ.3710.Christmas Game(博弈论 树上删边游戏 Multi-SG)

    题目链接 \(Description\) 给定n棵"树",每棵"树"的节点可能"挂着"一个环,保证没有环相交,且与树只有一个公共点. 两人轮 ...

  9. SpringMVC拷贝属性

    A a = new A(); B b = new B(); //将A的属性拷贝到B上 BeanUtils.copyProperties(a,b)

  10. STL——模拟实现空间配置器

    目录 问题 SGI版本空间配置器-std::alloc 一级空间配置器 二级空间配置器 Refill.chunkAlloc函数 最后,配置器封装的simple_alloc接口 问题 我们在日常编写C+ ...