将C语言定义的带有uion的结构体用Delphi定义---求助(17分)

  • 主题发起人 主题发起人 quietosea
  • 开始时间 开始时间
Q

quietosea

Unregistered / Unconfirmed
GUEST, unregistred user!
为什么IMAGE_RESOURCE_DIRECTORY_ENTRY结构在Delphi中没有定义呢?请帮忙改写: <br>typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {<br>&nbsp; &nbsp; union {<br>&nbsp; &nbsp; &nbsp; &nbsp; struct {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD NameOffset:31;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD NameIsString:1;<br>&nbsp; &nbsp; &nbsp; &nbsp; };<br>&nbsp; &nbsp; &nbsp; &nbsp; DWORD Name;<br>&nbsp; &nbsp; &nbsp; &nbsp; WORD Id;<br>&nbsp; &nbsp; };<br>&nbsp; &nbsp; union {<br>&nbsp; &nbsp; &nbsp; &nbsp; DWORD OffsetToData;<br>&nbsp; &nbsp; &nbsp; &nbsp; struct {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD OffsetToDirectory:31;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD DataIsDirectory:1;<br>&nbsp; &nbsp; &nbsp; &nbsp; };<br>&nbsp; &nbsp; };<br>} IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY;<br><br>
 
struct {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD NameOffset:31;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD NameIsString:1;<br>&nbsp; &nbsp; &nbsp; &nbsp; };<br>this cannot be defined in delphi
 
你应当使用变体记录类型<br>TRec = record<br>case i:integer of<br>&nbsp; 0:(v1 : real);<br>&nbsp; 1:(v2 : integer);<br>end;<br>等价于C当中的<br>union TRec{<br>&nbsp; float v1;<br>&nbsp; int v2; <br>}<br>你自己对照着改吧。
 
后退
顶部