Structure packing

Hey,

Does anyone know how to specify the structure packing of VB.NET's structures? I have a program which calls API functions that require structures and everything should work, but it doesn't. I'm suspicious of the structure member alignment of VB.NET which is probably 4 byte aligned. Does anyone know how to tell VB.NET to switch to 1 byte packing for a specific structure?

Best Regards,
Richard

The way I see it... Well, it's all pretty blurry

Comments

  • Maybe I [color=Blue]misunderstood[/color], but why not use another data type?
    Could be harder to make VB align to 1 byte, against using a Byte().
    Some situations could not be avoided, but VB isn't that flexible sometimes.

    [red]Good luck![/red]
    [blue]Hackman[/blue]
  • : Maybe I [color=Blue]misunderstood[/color], but why not use another
    : data type?
    : Could be harder to make VB align to 1 byte, against using a Byte().
    : Some situations could not be avoided, but VB isn't that flexible
    : sometimes.
    :
    : [red]Good luck![/red]
    : [blue]Hackman[/blue]

    Well if I have a structure, reading that structure from a Byte array is quite complicated. I guess it could be done if VB.NET supports direct byte copying. Else I'd have to start worrying about extra thing like endianness.

    So that's why I kind of want VB.NET to obey it's master.
    To make sure that I don't have to code complicatedly around it's inflexibility. And considering how byte packing is a normal phenomenon, and can cause great problems interacting with the Windows API's, I figure there just has to be some way to change the packing.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • I'm not saying using the Byte() and then copy to a structure.
    I said use the Byte() directly ?
    But at then end ... depends of your needs :)

    I couldn't did it, maybe I'm not a guru, but I used VB since 3.0
    and I use VB .NET 7,8 everyday to design all kind of applications,
    if you find how to do it ... well worts a blog.

    [red]Good luck![/red]
    [blue]Hackman[/blue]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories