C++  中定义结构体,
struct CObjectInterface
  {
   virtual int         __stdcall proc1(void);
   virtual time_t      __stdcall proc2(void);
   //--- firewall config access
   virtual int         __stdcall func1(const int pos, double *acc);
   virtual int         __stdcall func2(const int pos);
   virtual int         __stdcall func3(const int pos,double *acc);
   virtual int         __stdcall func4(const int pos,const int shift);
}Delphi 中如何定义啊

解决方案 »

  1.   

    在Delphi中声明成接口好像不行吧,强制都是遵从COM规范,从IUnknown继承下来的。
    如果是抽象类,C++中的struct又没有虚表,所以...
    下面提供参考,有大牛给过过眼,看是否可以这样定义。program Project1;{$APPTYPE CONSOLE}uses
      Windows;type
      int = integer;
      time_t = longint;type
      CObjectInterface = object
        function  proc1(): int;virtual;stdcall;abstract;
        function  proc2(): time_t;virtual;stdcall;abstract;
        //--- firewall config access
        function  func1(const pos: int; acc: Pdouble): int;virtual;stdcall;abstract;
        function  func2(const pos: int): int;virtual;stdcall;abstract;
        function  func3(const pos: int; acc: Pdouble): int;virtual;stdcall;abstract;
        function  func4(const pos; const shift: int): int;virtual;stdcall;abstract;
      end;begin
      { TODO -oUser -cConsole Main : Insert code here }
    end.
      

  2.   

    从D7开始(还是D5?),接口就不必非得从IUnknown继承了吧,可以从IInterface继承
      

  3.   

    IUnknown其实只是IInterface的马甲
      

  4.   

    C++的Sturct和Class除了成员默认公有私有之外没区别.
    type
      // C++有开关,Time_t可能映射为32位整数也可能映射为64位整数.你要自己去看下具体开关怎么设置的
      Time_t = Int64;  CObjectInterface = class
        function proc1(): Integer;virtual; stdcall;  abstract;
        function proc2(): Time_t; virtual; stdcall;  abstract;
        // --- firewall config access
        function func1(const pos: Integer; acc: PDouble): Integer;virtual; stdcall;  abstract;
        function func2(const pos: Integer): Integer; virtual; stdcall;  abstract;
        function func3(const pos: Integer; acc: PDouble): Integer; virtual; stdcall;  abstract;
        function func4(const pos: Integer; shift: Integer): Integer;
          virtual; stdcall;  abstract;
      end;
    上面是C++对象,Delphi调用的封装方式,如果是Delphi对象就把abstract去掉,自己实现一下