Allows you to manipulate memory addresses directly....
VB Code:
'\\ API declarations... Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, Source As Long, ByVal Length As Long) Private Declare Sub CopyMemoryByte Lib "kernel32" Alias "RtlMoveMemory" (Destination As Byte, Source As Long, ByVal Length As Long) Private Declare Sub CopyMemoryFromByte Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, Source As Byte, ByVal Length As Long)
These are then used in standard functions thus:
VB Code:
Public Function Peek(Address As Long) As Long Call CopyMemory(Peek, ByVal Address, Len(Address)) End Function Public Function PeekByte(Address As Long) As Byte Call CopyMemoryByte(PeekByte, ByVal Address, Len(PeekByte)) End Function Public Function Poke(Address As Long, Value As Long) CopyMemory ByVal Address, Value, LenB(Value) End Function Public Function PokeByte(Address As Long, Value As Byte) CopyMemoryFromByte ByVal Address, Value, LenB(Value) End Function
Example of use....
VB Code:
Dim lTest As Long lTest = 100 Debug.Print lTest Poke VarPtr(lTest), 300 Debug.Print lTest


Reply With Quote