我贴一个 PTypeData = ^TTypeData;
TTypeData = packed record
case TTypeKind of
tkUnknown, tkLString, tkWString, tkVariant: ();
tkInteger, tkChar, tkEnumeration, tkSet, tkWChar: (
OrdType: TOrdType;
case TTypeKind of
tkInteger, tkChar, tkEnumeration, tkWChar: (
MinValue: Longint;
MaxValue: Longint;
case TTypeKind of
tkInteger, tkChar, tkWChar: ();
tkEnumeration: (
BaseType: PPTypeInfo;
NameList: ShortStringBase));
tkSet: (
CompType: PPTypeInfo));
tkFloat: (
FloatType: TFloatType);
tkString: (
MaxLength: Byte);
tkClass: (
ClassType: TClass;
ParentInfo: PPTypeInfo;
PropCount: SmallInt;
UnitName: ShortStringBase;
{PropData: TPropData});
tkMethod: (
MethodKind: TMethodKind;
ParamCount: Byte;
ParamList: array[0..1023] of Char
{ParamList: array[1..ParamCount] of
record
Flags: TParamFlags;
ParamName: ShortString;
TypeName: ShortString;
end;
ResultType: ShortString});
tkInterface: (
IntfParent : PPTypeInfo; { ancestor }
IntfFlags : TIntfFlagsBase;
Guid : TGUID;
IntfUnit : ShortStringBase;
{PropData: TPropData});
tkInt64: (
MinInt64Value, MaxInt64Value: Int64);
end;
联合里面可以套联合的。
0: (h_addr_list: ^PChar);
1: (h_addr: ^PChar)
是什么意思呢
TRect = record
case Integer of
0: (Left, Top, Right, Bottom: Integer);
1: (TopLeft, BottomRight: TPoint);
end;
第一组的数据 (Left, Top, Right, Bottom: Integer)
和第二组数据(TopLeft, BottomRight: TPoint)使用的是同一块内存。
只是访问的方式不一样。
0: (h_addr_list: ^PChar);
1: (h_addr: ^PChar)
表示 记录 可以提供一个 h_addr_list 名称的字段,
也可以提供 h_addr 名称的字段 ,以便访问.
如果是16位的,就是 hostent = record
h_name: PChar;
h_aliases: ^PChar;
h_addrtype: Smallint;
h_length: Smallint;
h_addr_list: ^PChar);
end;
如果是32位的:
}
hostent = record
h_name: PChar;
h_aliases: ^PChar;
h_addrtype: Smallint;
h_length: Smallint;
h_addr: ^PChar ;
end;
case Boolean of
True :.................
False:.................
end ;
的情况,有什么讲究吗?
一个纪录可包括固定部分和变体部分,固定部分的域对该类型的所有变量是同样的,而变体部分的域对各个变量是不一定相同的,所以用到了Case进行条件选择,例子就不用写了吧,上面都很详细了。
第一步:Pascal
第二步:Object Pascal
第三步:VCL