Managing raw data with the MemoryBlock class

A MemoryBlock is used whenever you need a container for any arbitrary binary data.

A MemoryBlock object allocates a sequence of bytes in memory and manipulates those bytes directly. A MemoryBlock can be passed in place of a Ptr when used in a Declare call. For times when you need to directly manage a block of data in its raw (byte) form, you will need to use a MemoryBlock. When reviewing the API for creating Declare statements, you will find that some parameters require a pointer to a chuck of data. You can set up a memory block as the location for this data.

A MemoryBlock can be initialized with a String value. The byte contents of the string are assigned as the raw data for the MemoryBlock.

Var s As String = "Hello!"
Var mb As MemoryBlock
mb = s
MessageBox(mb.StringValue(0, mb.Size))

See also

MemoryBlock class