Address of a variable: Difference between revisions

(Added Visual Basic)
Line 178:
Allocates a stable address in unmanaged memory, copies a variable to it, then returns the address itself.
 
Dim x = 5
Dim ptrX As IntPtr
ptrX = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(Integer)))
Marshal.StructureToPtr(5, ptrX, False)
Dim addressX = ptrX.ToInt64
 
===Set the Address===
Sets the pointer to the address A100 in hex.
 
Dim ptrX As New IntPtr(&HA100)