473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

strucure with buffer

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
Nov 21 '05 #1
3 1159
Hi,

Redim buffer after you create the structure.

Dim m As myStruct
ReDim m.buffer(512)
Ken
--------------------
"Ralph Heger" <ra*********@softart.at> wrote in message
news:43***********************@newsreader.inode.at ...
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

Nov 21 '05 #2
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

"Ken Tucker [MVP]" <vb***@bellsouth.net> schrieb im Newsbeitrag
news:eC***************@TK2MSFTNGP10.phx.gbl...
Hi,

Redim buffer after you create the structure.

Dim m As myStruct
ReDim m.buffer(512)
Ken
--------------------
"Ralph Heger" <ra*********@softart.at> wrote in message
news:43***********************@newsreader.inode.at ...
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


Nov 21 '05 #3
Can you use:

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

--
Dennis in Houston
"Ralph Heger" wrote:
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

"Ken Tucker [MVP]" <vb***@bellsouth.net> schrieb im Newsbeitrag
news:eC***************@TK2MSFTNGP10.phx.gbl...
Hi,

Redim buffer after you create the structure.

Dim m As myStruct
ReDim m.buffer(512)
Ken
--------------------
"Ralph Heger" <ra*********@softart.at> wrote in message
news:43***********************@newsreader.inode.at ...
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



Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: inkapyrite | last post by:
Hi all. I'm using ifstream to read from a named pipe but i've encountered an annoying problem. For some reason, the program blocks on reading an ifstream's internal buffer that's only half-filled....
4
by: ma740988 | last post by:
A few days ago I recieved yet again advice on implementing a buffer of bytes. At issue: (part 1) how do I take the contents of a struct, then dump (used sparingly) it into a byte buffer. ...
2
by: William Stacey | last post by:
Working with implementing a circular buffer for a producer/consumer deal. Have not done one in a while. The following seems to work. However, I remember and have seen other implementation that...
6
by: nickdu | last post by:
I usually try to stay away from _alloca(). However, I'm considering using it for a logging function. Our current logging function maintains its own buffer which it grows to fit the string being...
5
by: arnuld | last post by:
this is from mentioned section. i did not understand some things here: it means "flushing the buffer" and "writing to output device" are SAME thing, these are just 2 different names for the...
4
by: aki | last post by:
Hi all, i am writing codes for implementing network protocols. i have written a method which is receiving a packet from network. i have assumed that the packet i will receive will be of type...
0
by: martinmercy2001 | last post by:
Could any body help me with creating a ring buffer class using a string. use memory circular buffer not an IO buffer. just read, write and seek method. Read method should take anumber and return the...
3
by: babu198649 | last post by:
hi i have a structure xml_data struct xml_data { int prf; int *pVsipl_buffer; };
36
by: James Harris | last post by:
Initial issue: read in an arbitrary-length piece of text. Perceived issue: handle variable-length data The code below is a suggestion for implementing a variable length buffer that could be used...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.