zoukankan      html  css  js  c++  java
  • C#调用COM组件的几个步骤

    < DOCTYPE html PUBLIC -WCDTD XHTML StrictEN httpwwwworgTRxhtmlDTDxhtml-strictdtd>

    这里我们将介绍C#调用COM组件的几个步骤,先将Com类型信息转换为.NET元数据,然后查看元数据,最后测试程序。

    首先将Com类型信息转换为.NET元数据

    1. tlbimp sample.dll /out: sample_clw.dll

    工具:Tlbimp.exe(类型库导入程序 )

    参考:.Net framework SDK 文档

    1. ms-help://MS.NETFrameworkSDK.CHS/cptools/html/cpgrftypelibraryimportertlbimpexe.htm

    查看元数据

    工具:ILDasm

    参考:ms-help://MS.NETFrameworkSDK.CHS/cptutorials/html/il_dasm_tutorial.htm

    测试程序:

    生成一个console programme

    在project->add reference里,选择com,browser你的com,select

    ok,现在在你的bin目录下应该有一个sample_clw.dll了

    下面我们来用sample_clw的方法

    1. using System;
    2. using sample_clw;
    3. namespace CompConsole
    4. {
    5. /// <summary>
    6. /// Class1 的摘要说明。
    7. /// </summary>
    8. class Class1
    9. {
    10. /// <summary>
    11. /// 应用程序的主入口点。
    12. /// Date:2003/6/20
    13. /// </summary>
    14. [STAThread]
    15. static void Main(string[] args)
    16. {
    17. //
    18. // TODO: 在此处添加代码以启动应用程序
    19. Console.Write ("=======Demo for Call com functions in c#=============\n");
    20. sampleClass sam = new sampleClass();
    21. //now we call functions
    22. //
    23. sam.SayHello();
    24. }
    25. }
  • 相关阅读:
    ES6中的模板字符串使用方法
    windows下手动安装composer
    搬运 centos7.2 apache 绑定二级目录 访问依然是apache页面
    博客园样式修改
    Linux系统小知识
    Tcahce Stashing Unlink Attack
    vps+v_2_ray+proxychains
    环境问题记录
    web
    2020BJDCTF
  • 原文地址:https://www.cnblogs.com/netcorner/p/2911989.html
Copyright © 2011-2022 走看看