如何定义“UCHAR * POINTER_32"和“VOID * POINTER_32"Delphi 中的类型? [英] How to define "UCHAR * POINTER_32" and "VOID * POINTER_32" types in Delphi?
问题描述
翻译IP_OPTION_INFORMATION32
和 ICMP_ECHO_REPLY32
用于 64 位编译器的结构我被困在那里使用的数据类型.参考文献中的结构定义:
Translating the IP_OPTION_INFORMATION32
and ICMP_ECHO_REPLY32
structures for 64-bit compiler I got stucked with data types to use there. Structure definitions from the reference:
IP_OPTION_INFORMATION32 结构:
typedef struct _IP_OPTION_INFORMATION32 {
UCHAR Ttl;
UCHAR Tos;
UCHAR Flags;
UCHAR OptionsSize;
UCHAR * POINTER_32 OptionsData;
} IP_OPTION_INFORMATION32, *PIP_OPTION_INFORMATION32;
我会这样翻译(对于 Delphi XE2,64 位目标平台).如您所见,我不知道该结构的 OptionsData
字段使用什么类型:
I would translate this way (for Delphi XE2, 64-bit target platform). As you can see, I don't know what type to use for the OptionsData
field of the structure:
IP_OPTION_INFORMATION32 = record
Ttl: UCHAR;
Tos: UCHAR;
Flags: UCHAR;
OptionsSize: UCHAR;
OptionsData: // what should I use here for UCHAR * POINTER_32 ?
end;
ICMP_ECHO_REPLY32 结构:
typedef struct icmp_echo_reply32 {
IPAddr Address;
ULONG Status;
ULONG RoundTripTime;
USHORT DataSize;
USHORT Reserved;
VOID * POINTER_32 Data;
struct ip_option_information32 Options;
} ICMP_ECHO_REPLY32, *PICMP_ECHO_REPLY32;
对于 Delphi XE2 64 位目标平台,我会写:
For Delphi XE2 64-bit target platform I would write:
ICMP_ECHO_REPLY32 = record
Address: TIPAddr; // defined before
Status: ULONG;
RoundTripTime: ULONG;
DataSize: USHORT;
Reserved: USHORT;
Data: // what should I use here for VOID * POINTER_32 ?
Options: IP_OPTION_INFORMATION32;
end;
问题:
您将如何在 Delphi 中为 64 位平台目标定义 UCHAR * POINTER_32
和 VOID * POINTER_32
类型?据我所知,没有可用于 64 位平台目标的 32 位指针类型,我只是不喜欢定义它,例如作为 Int32
类型:-)
Question:
How would you define the UCHAR * POINTER_32
and VOID * POINTER_32
types in Delphi for 64-bit platform target ? As far as I know, there is no 32-bit pointer type available for 64-bit platform target and I just don't like it to be defined e.g. as a Int32
type :-)
上述类型最准确的翻译是什么?
What is the most precise translation for the mentioned types ?
推荐答案
POINTER_32
在另一个 Stack Overflow 问题中涵盖的问题:POINTER_32 - 它是什么,为什么?
The issue of what POINTER_32
is covered in another Stack Overflow question: POINTER_32 - what is it, and why?
在与在不同进程中定义的结构(具有 32 位指针)执行互操作时,您会使用它.
You would use it when performing interop with structs that are defined in a different process, one that has 32 bit pointers.
您在 Delphi 中没有 __ptr32
等价物,因此您别无选择,只能将其声明为 32 位整数.我会使用无符号类型.
You don't have the equivalent of __ptr32
in Delphi so you have simply no choice other than to declare it as a 32 bit integer. I would use an unsigned type.
这篇关于如何定义“UCHAR * POINTER_32"和“VOID * POINTER_32"Delphi 中的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!