strucure with buffer

  • Thread starter Thread starter Ralph Heger
  • Start date Start date
R

Ralph Heger

Hi

An API-Function I want to use needs a structure as parameter:

public structure myStruct
dim i1 as short
dim i2 as byte
dim i3 as integer
dim buffer as byte()
end structure

buffer is an array of fixed length. But how could I correctly declare
buffer, so that is really behind i3 in memory? <VBFixedArray(512)> doesn't
work in that case, and declaring b1, b2, b3, b4,... as byte does work, but
who wouild really want to do that.
Any ideas?

thanks

Ralph
 
Hi,

Redim buffer after you create the structure.

Dim m As myStruct
ReDim m.buffer(512)


Ken
 
Thanks, Ken

I have got a solution from an other usegroup. The problem with your solution
is, that you can't be sure that the memory that 'buffer' needs is on the
wright location. But declaring buffer with
'<MarshalAs(UnmanagedType.ByValArray, SizeConst := 512)>' does the job.

thanks
Ralph
 
Can you use:

<StructLayout(LayoutKind.Sequential)> _
Public Structure MyStructure
.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top