DataType

Ptr


Description

A reference to a chunk of memory. You can pass a MemoryBlock object via this data type and it will be treated as a pointer to the memory contained within the MemoryBlock.

Methods

Name

Parameters

Returns

Shared

Boolean

offset As Integer = 0

Boolean

Byte

offset As Integer = 0

Byte

CFStringRef

offset As Integer = 0

CFStringRef

Color

offset As Integer = 0

Color

CString

offset As Integer = 0

CString

Currency

offset As Integer = 0

Currency

Double

offset As Integer = 0

Double

Int16

offset As Integer = 0

Int16

Int32

offset As Integer = 0

Int32

Int64

offset As Integer = 0

Int64

Int8

offset As Integer = 0

Int8

Integer

offset As Integer = 0

Integer

Single

offset As Integer = 0

Single

Structure

offset As Integer = 0

Structure

UInt16

offset As Integer = 0

UInt16

UInt32

offset As Integer = 0

UInt32

UInt64

offset As Integer = 0

UInt64

UInt8

offset As Integer = 0

UInt8

UInteger

offset As Integer = 0

UInteger

WString

offset As Integer = 0

WString

Method descriptions


Ptr.Boolean

Boolean(offset As Integer = 0) As Boolean

Converts the value referenced to by the pointer to a Boolean.


Ptr.Byte

Byte(offset As Integer = 0) As Byte

Converts the value referenced to by the pointer to a Byte.


Ptr.CFStringRef

CFStringRef(offset As Integer = 0) As CFStringRef

Converts the value referenced to by the pointer to a CFStringRef.


Ptr.Color

Color(offset As Integer = 0) As Color

Converts the value referenced to by the pointer to a Color.


Ptr.CString

CString(offset As Integer = 0) As CString

Converts the value referenced to by the pointer to a CString.


Ptr.Currency

Currency(offset As Integer = 0) As Currency

Converts the value referenced to by the pointer to a Currency.


Ptr.Double

Double(offset As Integer = 0) As Double

Converts the value referenced to by the pointer to a Double.


Ptr.Int16

Int16(offset As Integer = 0) As Int16

Converts the value referenced to by the pointer to an Int16.


Ptr.Int32

Int32(offset As Integer = 0) As Int32

Converts the value referenced to by the pointer to an Int32.


Ptr.Int64

Int64(offset As Integer = 0) As Int64

Converts the value referenced to by the pointer to an Int64.


Ptr.Int8

Int8(offset As Integer = 0) As Int8

Converts the value referenced to by the pointer to an Int8.


Ptr.Integer

Integer(offset As Integer = 0) As Integer

Converts the value referenced to by the pointer to an Integer.


Ptr.Single

Single(offset As Integer = 0) As Single

Converts the value referenced to by the pointer to a Single.


Ptr.Structure

Structure(offset As Integer = 0) As Structure

Converts the value referenced to by the pointer to a specific Structure type.

Given a structure, you can dereference it from a pointer like this:

Structure TestStruct
  Value As Int64
End Structure
Var p As Ptr ' assign an appropriate Ptr value
Var structVar As TestStruct = p.TestStruct

structVar.Value = 42

Ptr.UInt16

UInt16(offset As Integer = 0) As UInt16

Converts the value referenced to by the pointer to an UInt16.


Ptr.UInt32

UInt32(offset As Integer = 0) As UInt32

Converts the value referenced to by the pointer to an UInt32.


Ptr.UInt64

UInt64(offset As Integer = 0) As UInt64

Converts the value referenced to by the pointer to an UInt64.


Ptr.UInt8

UInt8(offset As Integer = 0) As UInt8

Converts the value referenced to by the pointer to an UInt8.


Ptr.UInteger

UInteger(offset As Integer = 0) As UInteger

Converts the value referenced to by the pointer to an UInteger.


Ptr.WString

WString(offset As Integer = 0) As WString

Converts the value referenced to by the pointer to a WString.

Notes

A Ptr is 4 bytes for 32-bit apps and 8 bytes for 64-bit apps.

You can compare one Ptr to another Ptr or to Nil.

You can convert the value referenced to by the pointer to a specific data type using the available methods.

You can assign a Ptr to a MemoryBlock.

You can convert the value referenced to by the pointer to a specific datatype using the Pointer Properties: Boolean, Byte, CFStringRef, Class, Color, CString, Currency, Double, Int16, Int32, Int64, Int8, Integer, Object, Ptr, Short, Single, UInt16, UInt32, UInt64, UInt8, WString.


You can compare one Ptr to another or to Nil.

Sample code

Var p1, p2, p3 As Ptr

p1 = AddressOf someMethod
p2 = someMemoryBlock ' A Ptr to the MemoryBlock itself
p3 = someMemoryBlock.Ptr(n) ' Retrieve Ptr stored within the MemoryBlock at offset n

Compatibility

All project types on all supported operating systems.

See also

AddressOf method; Declare statement; MemoryBlock class; MemoryBlock.Ptr function, OSHandle class.