typedef struct _EXT_FRAME_HEAD
{
    unsigned long nStartFlag; //扩展帧头起始标识
    unsigned short nVer; //版本
    unsigned short nLength; //扩展帧头长度
EXT_FRAME_TYPE szFrameInfo;
unsigned long   nTimestamp; //以毫秒为单位的时间戳
unsigned long nEndFlag; //扩展帧头起始标识 bool CheckExtFlag()
{
return (HH_EXT_HEAD_FLAG == nStartFlag && HH_EXT_TAIL_FLAG == nEndFlag ) ? true:false;
}
}EXT_FRAME_HEAD;typedef struct _HV_FRAME_HEAD
{
unsigned short zeroFlag; // 0
unsigned char   oneFlag; // 1
unsigned char streamFlag; // 数据帧标志 FRAME_FLAG_VP,FRAME_FLAG_VI,FRAME_FLAG_A

unsigned long nByteNum; //数据帧大小
unsigned long nTimestamp; //时间戳
}HV_FRAME_HEAD;上面2个结构体
下面这句 要转 delphi, 折腾了好久 怎么编译器都过不了
EXT_FRAME_HEAD *pExtFrameHead = (EXT_FRAME_HEAD *)((char*)pFrameHead + sizeof(HV_FRAME_HEAD));
这句意思应该是 定义一个EXT_FRAME_HEAD类型的指针变量, 然后赋值, 但在delphi中如何转呢?type
  EXT_FRAME_HEAD = record
    nStartFlag: LongInt; //扩展帧头起始标识
    nVer: Word; //版本
    nLength: Word; //扩展帧头长度
    szFrameInfo: EXT_FRAME_TYPE;
    nTimestamp: LongInt; //以毫秒为单位的时间戳
    nEndFlag: LongInt; //扩展帧头起始标识//这里不会翻译, 但跟本次无关, 不过有知道怎么翻的前辈指点下,  不胜感激
//         public bool CheckExtFlag()
//         {
//         return (HH_EXT_HEAD_FLAG == nStartFlag && HH_EXT_TAIL_FLAG == nEndFlag ) ? true:false;
//         }
  end;
  pEXT_FRAME_HEAD = ^EXT_FRAME_HEAD;type
  HV_FRAME_HEAD = record
    zeroFlag: Word; // 0
    oneFlag: Byte; // 1
    streamFlag: Byte; // 数据帧标志 FRAME_FLAG_VP,FRAME_FLAG_VI,FRAME_FLAG_A
    nByteNum: LongInt; //数据帧大小
    nTimestamp: LongInt; //时间戳
  end;
  pHV_FRAME_HEAD = ^HV_FRAME_HEAD;
var
  pFrameHead : pHV_FRAME_HEAD;
  pExtFrameHead: pEXT_FRAME_HEAD;然后呢 ..... 

解决方案 »

  1.   

    结构体定义时用 packed record 让它的成员向前靠紧.
      

  2.   

     bool CheckExtFlag()
        {
            return (HH_EXT_HEAD_FLAG == nStartFlag && HH_EXT_TAIL_FLAG == nEndFlag ) ? true:false;
        }function CheckExtFlag():boolean;
    begin
    result := (HH_EXT_HEAD_FLAG =(nStartFlag and HH_EXT_TAIL_FLAG=nEndFlag ));
    end;
      

  3.   

    这句 可是在c++定义的结构体里面呀, 像你这么写在结构体里,  还没编译, delphi就给出错误提示了
      

  4.   

     
    var
      pFrameHead : pHV_FRAME_HEAD;
      pExtFrameHead: pEXT_FRAME_HEAD;
    pExtFrameHead := @(pFrameHead^);
    这么写可以编译通过, 但显然跟c++的语句还差好多
      

  5.   

    pExtFrameHead:=  pEXT_FRAME_HEAD(LongWord(pFrameHead) + SizeOf(HV_FRAME_HEAD));
    转成这样 , 可以吗?, 编译可以通过, 但实际有没有效果, 现在无法判断
      

  6.   

    type
      EXT_FRAME_HEAD = record
        nStartFlag: LongInt;            //扩展帧头起始标识
        nVer: Word;                //版本
        nLength: Word;            //扩展帧头长度
        szFrameInfo: EXT_FRAME_TYPE;
        nTimestamp: LongInt;            //以毫秒为单位的时间戳
        nEndFlag: LongInt;            //扩展帧头起始标识
        function CheckExtFlag: boolean;
      end;function EXT_FRAME_HEAD.CheckExtFlag: boolean;
    begin
      result := (HH_EXT_HEAD_FLAG = nStartFlag) and (HH_EXT_TAIL_FLAG = nEndFlag);
    end;   
      

  7.   

    EXT_FRAME_HEAD    *pExtFrameHead = (EXT_FRAME_HEAD *)((char*)pFrameHead + sizeof(HV_FRAME_HEAD));var
      pExtFrameHead: ^EXT_FRAME_HEAD;pExtFrameHead := pointer(NativeInt(pFrameHead) + sizeof(HV_FRAME_HEAD));
      

  8.   


    delphi 结构体里也可放函数啊!!!!!!!!!!
      

  9.   


    delphi 结构体里也可放函数啊!!!!!!!!!!d7以后的版本,结构和类类似了,除了几点区别:(引自帮助)Records (advanced) In addition to the traditional record types, the Delphi language allows more complex and "class-like" record types. In addition to fields, records may have properties and methods (including constructors), class properties, class methods, class fields, and nested types. For more information on these subjects, see the documentation on Classes and Objects. Here is a sample record type definition with some "class-like" functionality.  type
       TMyRecord = record
         type
           TInnerColorType = Integer;
         var
           Red: Integer;
         class var
           Blue: Integer;
         procedure printRed();
         constructor Create(val: Integer);
         property RedProperty: TInnerColorType read Red write Red;
         class property BlueProp: TInnerColorType read Blue write Blue;
     end;
     
     constructor TMyRecord.Create(val: Integer);
     begin
       Red := val;
     end;
     
     procedure TMyRecord.printRed;
     begin
       Writeln('Red: ', Red);
     end;Though records can now share much of the functionality of classes, there are some important differences between classes and records. 1,Records do not support inheritance. 
    2,Records can contain variant parts; classes cannot. 
    3,Records are value types, so they are copied on assignment, passed by value, and allocated on the stack unless they are declared globally or explicitly allocated using the New and Dispose function. Classes are reference types, so they are not copied on assignment, they are passed by reference, and they are allocated on the heap. 
    4,Records allow operator overloading on the Win32 platform; classes, however, do not allow operator overloading. 
    5,Records are constructed automatically, using a default no-argument constructor, but classes must be explicitly constructed. Because records have a default no-argument constructor, any user-defined record constructor must have one or more parameters. 
    6,Record types cannot have destructors. 
    7,Virtual methods (those specified with the virtual, dynamic, and message keywords) cannot be used in record types. 
    8,Unlike classes, record types on the Win32 platform cannot implement interfaces.