zoukankan      html  css  js  c++  java
  • COM中的error handling机制及示例(ISupportEfforInfo,ICreateErrorInfo,IErrorInfo)

    COM采取通过返回HRESULT code的方式来获取COM调用的结果。但是往往返回的HRESULT非常抽象。为了使返回的Error information 更加具有可读性,COM支持ISupportErrorInfo interface来对Error information进行具体描述。

    在COM service中返回一个具体的Error information过程如下所示:

    参阅文章:http://msdn.microsoft.com/en-us/library/ms221062.aspx

    在COM client 中检索error information的过程如下所示:

    参阅文章:http://msdn.microsoft.com/en-us/library/ms221026.aspx

    如何实现这种基于IErrorInfo的错误处理机制,可以参阅Microsoft Support KB:http://support.microsoft.com/kb/139073/en-us

    下面的demo演示了通过ISupportErrorInfo interface, ICreateErrorInfo interface, IErrorInfo interface,以及CreateErrorInfo() API, SetErrorInfo() API和smart pointer来实现Error Handling .

    COM service side:

    =========
    COM IDL File

    Code

     SimpleClass Header File:

    Code

    SimpleClass Implementation:

    Code

    COM Client:

    ============
    Client code:

    Code

    关于此demo的source code,点击此处下载

  • 相关阅读:
    1026: C语言程序设计教程(第三版)课后习题7.5
    1024: C语言程序设计教程(第三版)课后习题7.3
    1023: C语言程序设计教程(第三版)课后习题7.2
    1022: C语言程序设计教程(第三版)课后习题7.1
    1021: C语言程序设计教程(第三版)课后习题6.11
    1020: C语言程序设计教程(第三版)课后习题6.10
    1019: C语言程序设计教程(第三版)课后习题6.9
    1018: C语言程序设计教程(第三版)课后习题6.8
    1017: C语言程序设计教程(第三版)课后习题6.7
    mac电脑很卡,如何在命令行查看当前电脑中的运行状态
  • 原文地址:https://www.cnblogs.com/Winston/p/1487250.html
Copyright © 2011-2022 走看看