// *********************************************************************//
  _IApplicationEvents = dispinterface
    ['{3C31BF76-2837-4BFA-A19E-34485A213F29}']
    procedure ReceiveCurConf(var Conf: OleVariant); dispid 1;
    procedure StatusChange(Status: Integer; const bstrDetail: WideString); dispid 2;
  end;IApplication = interface(IDispatch)
    ['{98AA9DD3-0715-4170-8A96-04F06C8BAD49}']
    procedure Connect(shType: Smallint; const bstrServerIP: WideString; const bstrUser: WideString; 
                      const bstrPass: WideString); safecall;
    procedure DisConnect; safecall;
    function IsConnect: Smallint; safecall;
    function GetSessions: IDispatch; safecall;
    procedure Exit; safecall;
    procedure ShowServer; safecall;
    function GetCurrentAccount: WideString; safecall;
    function GetCurrentHost: WideString; safecall;
  end;// *********************************************************************//
// DispIntf:  IApplicationDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {98AA9DD3-0715-4170-8A96-04F06C8BAD49}
// *********************************************************************//
  IApplicationDisp = dispinterface
    ['{98AA9DD3-0715-4170-8A96-04F06C8BAD49}']
    procedure Connect(shType: Smallint; const bstrServerIP: WideString; const bstrUser: WideString; 
                      const bstrPass: WideString); dispid 1;
    procedure DisConnect; dispid 2;
    function IsConnect: Smallint; dispid 3;
    function GetSessions: IDispatch; dispid 4;
    procedure Exit; dispid 5;
    procedure ShowServer; dispid 6;
    function GetCurrentAccount: WideString; dispid 7;
    function GetCurrentHost: WideString; dispid 8;
  end;procedure ReceiveCurConf   StatusChange
这两个咋调用,处理?

解决方案 »

  1.   

    http://www.swissdelphicenter.ch/torry/showcode.php?id=2058
      

  2.   

    我去看了,可我还是不太明白,能不能以我的TLB文件中的定义说明一下。
    _IApplicationEvents = dispinterface
    即是内部接口,又是一个派遣接口,(不知道我理解的对不对)
    首先咋定义变量,是不是的INVOKE,等等,就是希望大家给解释一下,
    最终我能用这个接口。
    在此深表感谢
      

  3.   

    _IApplicationEvents
    你是需要自己实现这个接口的对象.
    然后'挂'到那个IApplication的COM组件对象上去..'挂'的过程,COM技术中,被称为'连接点'技术.简单过程是:
    1,查询取得组件对象的IConnectionPointContainer接口指针.
    2,通过IConnectionPointContainer接口指针查找连接点(FindConnectionPoint)
    3,把自己实现的_IApplicationEvents对象(可以称它事件响应对象),通过2取到的连接点接口
       Advise上去.
    这样,你的事件响应对象就'挂'上去了.要不再响应事件,调用连接点接口的Unadvise
      

  4.   

    呵呵,书上和网上我都没有找到DELPHI 这个方面的实例,
    好多概念又看不懂,网络上对DELPHI的连接点内容讲的很少。
    能给个EXAMPLE吗?
      

  5.   

    谁要TLB文件,和有例子发给我的话,[email protected]
      

  6.   

    也给我发一份吧: [email protected]
      

  7.   

    楼主也太懒了吧,jiangsheng(蒋晟.Net[MVP]) 贴的链接看都不看.
    那不是非常好的例子吗?
      

  8.   

    那个例子好像不是调用COM的啊!
      

  9.   

    那例子不是才怪.COM技术是相对较艰深的技术,用DELPHI使用它,已经相对C++用它有相当大的便捷.
    但该学的还是要学.
      

  10.   

    愚笨啊,哪位给贴一个EXAMPLE啊,
      

  11.   

    呵,那代码还没看明白?那代码里面:
    TIEEvents = class(TComponent, IUnknown, IDispatch)
    这儿定义的TIEEvents 就是你要学着定义的事件响应对象.-------------------------------------------------------
    看TIEEvents类,
    要实现的接口就两个IUnknown,IDispatch   // Protected declaratios for IUnknown
        function QueryInterface(const IID: TGUID; out Obj): HResult; override;
        function _AddRef: Integer; stdcall;
        function _Release: Integer; stdcall;     // Protected declaratios for IDispatch
        function GetIDsOfNames(const IID: TGUID; Names: Pointer; NameCount, LocaleID:
          Integer; DispIDs: Pointer): HResult; virtual; stdcall;
        function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; virtual; stdcall;
        function GetTypeInfoCount(out Count: Integer): HResult; virtual; stdcall;
        function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
          Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; virtual; stdcall;
         // Protected declarations-----------------------------------------------------
      _IApplicationEvents = dispinterface
        ['{3C31BF76-2837-4BFA-A19E-34485A213F29}']
        procedure ReceiveCurConf(var Conf: OleVariant); dispid 1;
        procedure StatusChange(Status: Integer; const bstrDetail: WideString); dispid 2;
      end;注意看每个方法后的dispid, 这表示dispinterface调用时,是通过传dispid值=1来代码调用了第一个方法.于是,你在实现你自己的事件响应对象时,就象学着
    TIEEvents.Invoke方法定义里面那样去判断dispid值而作相应处理.
    ------------------------------------------------------
      

  12.   

    楼主,这个问题解决了么?求指教
    我现在有一个c++写得com组件,已经注册了,声明接口的我都能成功实例化并且调用其内的方法,但是有一个事件接口声明的是dispinterface,我调不出其中的方法,急啊!!!