如何把这个c++ 的struct 转换成delphi 格式?(很短小的一个struct)(100分)

  • 主题发起人 主题发起人 mycoolis
  • 开始时间 开始时间
M

mycoolis

Unregistered / Unconfirmed
GUEST, unregistred user!
typedef struct {
DWORD dwOption;
// option to be queried or set
union {
DWORD dwValue;
// dword value for the option
LPSTR pszValue;
// pointer to string value for the option
FILETIME ftValue;
// file-time value for the option
} Value;
} MY_STRUCT;
先谢啦~
 
type
My_struct = record
dwOption: DWORD;
value: variant;
end;
 
楼上的,
漂亮,给你点掌声。。。
 
不是这么写吧,这在Delphi称为变体记录,和变体类型不同,好像这样:
My_struct = record
dwOption: DWORD;
Case Integer of
0: dwValue:DWORD;
1: pszValue PAnsiChar;
2: ftValue TFileTime:
end;
 
楼上的说的不错,但写的不对,应该是
My_struct = record
dwOption: DWORD;
Case Integer of
0: (dwValue: DWORD);
1: (pszValue: PAnsiChar);
2: (ftValue: [red]???[/red]):
end;
end;
[red]但是我不知道c++中FILETIME是什么类型所以就使用了variant[/red]
 
Who is right,who is wrong? I'm a rookie!
 
//但是我不知道c++中FILETIME是什么类型所以就使用了variant
就是TDateTime阿
 
这样啊!那答案就是:
My_struct = record
dwOption: DWORD;
Case Integer of
0: (dwValue: DWORD);
1: (pszValue: PAnsiChar);
2: (ftValue: TDateTime):
end;
end;
 
谢谢指正,正确得写法:
My_struct = record
dwOption: DWORD;
Case Integer of
0: (dwValue:DWORD);
1: (szValue:PAnsiChar);
2: (tValue:TFileTime);
end;
 
TDateTime实际上是Double,想也不会是C++中的FileTime,如果没有记错的话,FileTime
应该是一个结构体
 
还是用variant省事:)
 
我有一事不明,
你们定义integer(编译能通过吗?)了吗?
还是根本就不需要定义,
怎么使用这个变体记录,
我想取integer=2这种情况
是不是在给datetime之前写integer1=2;
请给出写入与读取的代码
 
请恕哥们愚昧,
以为是关键字错,实际上没错,
type
TShapeList = (Rectangle, Triangle, Circle, Ellipse, Other);
TFigure = record
case TShapeList of
Rectangle: (Height, Width: Real);
Triangle: (Side1, Side2, Angle: Real);
Circle: (Radius: Real);
Ellipse, Other: ();
end;
看这段例子,
定义Tshapelist四个值,有什么用
 
也就是怎么用,怎么判断现在变体记录里存放的是什么东西
 
后退
顶部