我的 C++ 应用程序中有这个结构:
struct textField
{
//0
union nameField
{
void* ptr;
char cstring[16];
} text;
//16
uint8_t textLength;
//17
char unknown1[3];
//20
uint8_t fieldType;
//21
char unknown2[3];
//24
uint32_t unknown3;
//28
};
我知道在 VB6 中,它看起来像这样:
Private Type textField ' 0
cstring(0 To 15) As Byte ' 16
textLength As Byte ' 17
unknown1(0 To 2) As Byte ' 20
fieldType As Byte ' 21
unknown2(0 To 2) As Byte ' 24
unknown3 As Long ' 28
End Type
但是结构中的 union 呢?如何实现?
最佳答案
最简单的方法是使用变体类型——它可以包含任何其他类型。
请注意,可能没有将 void *
直接映射到 VB 中,因此您需要研究 union 的使用方式,而不仅仅是快速转换。
关于c++ - 将 C++ union 结构转换为 VB6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13672632/