如何将下面的c结构改成delphi的记录类型:
typedef struct {
    unsigned long version_major;
    unsigned long version_minor;
    void     *current_attribute;
    unsigned long  port_type;
    char           port_name[128];
    unsigned short port_number;
    unsigned short port_connection_tries;    HANDLE     port_fd;     
    SOCKET     port_socket;
    int            receive_block;
    char           debug_name[128];
    FILE           *debug_log;
    unsigned char  wsdebug; 
    char           error_string[80];
} g4_inter_t;

解决方案 »

  1.   

    下面是我改的结果:(编译通不过)
     type g4_inter_t =Record
          version_major:longword;
          version_minor:longword;
          current_attribute:^pointer;
          port_type:longword;
          port_name:array[0..128] of char;
          port_number:word;
          port_connection_tries:word;
          prot_fd:Thandle;
          port_socket:Tsocket;
          receive_block:integer;
          debug_name:array[0..128] of char;
          debug_log:^file;
          wsdebug:widechar;
          error_string:array[0..80] of char;
      end;
      

  2.   

    port_socket:Tsocket; //这里报错么?
      

  3.   

    g4_inter_t =packed Record
          version_major:longword;
          version_minor:longword;
          current_attribute: pointer;
          port_type:longword;
          port_name:array[0..127] of char;
          port_number:word;
          port_connection_tries:word;
          prot_fd:Thandle;
          port_socket:Tsocket;
          receive_block:integer;
          debug_name:array[0..127] of char;
          debug_log:^file;
          wsdebug:byte;
          error_string:array[0..79] of char;
      end;
      

  4.   

    Dephi不熟...天知道是什么原因..友情UP
      

  5.   

    我看你自己都翻译得差不多了。调用时要加 uses WinSock,因为用到Tsocket
    C里面 char  debug_name[128]; delphi里面的范围时 [0..127]的
      

  6.   

    g4_inter_t =packed Record
          version_major:longword;
          version_minor:longword;
          current_attribute: pointer;
          port_type:longword;
          port_name:array[0..127] of char;
          port_number:word;
          port_connection_tries:word;
          prot_fd:Thandle;
          port_socket:socket;
          receive_block:integer;
          debug_name:array[0..127] of char;
          debug_log:^file;
          wsdebug:byte;
          error_string:array[0..79] of char;
      end;
      

  7.   

    感谢各位的帮忙.上面的结构没问题了.
    但我现在的关键问题要用到一个dll文件中的函数.该函数的返回值是上面这个结构类型的指针.
    我在程序中导入这个函数:
    function G4Open(BaseStationName:pchar;const status:Longint;const error_string:pchar;CustomInfoTable:^pointer;const CustomInfoFileName:array of char):^g4_inter_t;stdcall;external DLLNAME ;
    编译时指向这一行报错[Error] intermec2100Def.pas(36): Identifier expected but '^' found
      

  8.   

    Pg4_inter_t=^g4_inter_t;
    function G4Open(BaseStationName:pchar;const status:Longint;const error_string:pchar;CustomInfoTable:^pointer;const CustomInfoFileName:array of char):Pg4_inter_t;stdcall;external DLLNAME ;
      

  9.   

    问题应该解决了吧,delphi不像c可以直接用*pg4_inter_t,必须独立开来