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. }
  • 相关阅读:
    凡是可能出错的事必定会出错
    php session 前后台同域名下
    mysql常用; group by 高级
    Thread 学习记录 <1> -- volatile和synchronized
    VBA学习
    EXPLAINING WHAT ACTION AND FUNC ARE
    Unslider.js Tiny Sample
    jQuery操作DOM元素
    在.net中使用GAC
    Sql Server 分区演练 【转】
  • 原文地址:https://www.cnblogs.com/netcorner/p/2911989.html
Copyright © 2011-2022 走看看