编组日期类型
我正在尝试封送 VB6 结构,但我不知道如何封送日期类型,例如: DateSaved As Date
和以下字符串数组: FASTNESSNAME(1 到 6) As String * 16
提前感谢您的帮助。
I'm trying to marshal a VB6 structure but I don't know how to marshal the Date type ex:
DateSaved As Date
and the following array of strings:
FASTNESSNAME(1 To 6) As String * 16
Thanks in advance for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
VB6 中的日期与 .NET 中的日期非常相似(都是 8 字节),因此您应该将其编组为 System.DateTime。
.NET 中不支持固定长度字符串和基于 1 的数组。对于固定长度的字符串,您可以只使用自定义 .NET 类吗?
除此之外,您还可以使用
来定义固定字符串,但这与您在 VB6 中期望的方式不同。如果您在结构中使用它:然后在代码中使用 - 您可以获得不同的结果:
Dates in VB6 are very similar to dates in .NET (both are 8 bytes) so you should marshal as System.DateTime.
Fixed length strings and 1 based arrays are not supported as such in .NET. For the fixed length strings you could just use a custom .NET class?
As an addition to this you can use
<VBFixedString(20)>
to define a fixed string, but this doesn't work in the same way as you would expect in VB6. If you use this in a structure:And then use in your code - you can get differing results: