June 17, 2000

PeekB, PeekI, PeekL – Read a byte, integer or long from memory

Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (dest As _ Any, source As Any, ByVal bytes As Long)’ read a byte from memoryFunction PeekB(ByVal address As Long) As Byte CopyMemory PeekB, ByVal address, 1End Function’ read an integer from memoryFunction PeekI(ByVal address As Long) As Integer CopyMemory PeekI, ByVal

Peek – Read a value of any type from memory

Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (dest As _ Any, source As Any, ByVal bytes As Long)’ read a value of any type from memoryFunction Peek(ByVal address As Long, ByVal ValueType As VbVarType) As Variant Select Case ValueType Case vbByte Dim valueB As Byte CopyMemory valueB, ByVal address,

Poke – Write a value of any type into memory

‘ write a value of any type in memory” The value is written in the format of the value passed’ as the second argument, but you can overwrite it by passing’ an explicit data type in the third argument (this is the only’ way to store a value as a

StringFromBSTR – Convert a BSTR to a VB string

Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (dest As _ Any, source As Any, ByVal bytes As Long)’ convert a BSTR into a VB StringFunction StringFromBSTR(ByVal pointer As Long) As String Dim temp As String ‘ copy the pointer into the temporary string’s BSTR CopyMemory ByVal VarPtr(temp), pointer, 4

StringFromAddr – Read a string at a given address

Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (dest As _ Any, source As Any, ByVal bytes As Long)Private Declare Function lstrlenA Lib “kernel32” (ByVal lpString As Long) As _ LongPrivate Declare Function lstrlenW Lib “kernel32” (ByVal lpString As Long) As _ Long’ retrieve a string at a given address’

The age of a person

You can quickly evaluate the age of a person using the following function: Function Age(BirthDate As Date, Optional CurrentDate As Variant) As Integer If IsMissing(CurrentDate) Then CurrentDate = Now Age = Year(CurrentDate) – Year(BirthDate)End Property If you omit the second argument, the age is evaluate at the current time, but

EasterDate – Evaluate the date of Easter for a given year

‘ Evaluate the Easter date for a given yearFunction EasterDate(ByVal Year As Integer) As Date Dim G As Integer Dim C As Integer Dim H As Integer Dim i As Integer Dim j As Integer Dim L As Integer Dim Month As Integer Dim Day As Integer G = Year

PokeB, PokeI, PokeL – Write a byte, integer or long value into memory

Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (dest As _ Any, source As Any, ByVal bytes As Long)’ write a byte into memorySub PokeB(ByVal address As Long, ByVal value As Byte) CopyMemory ByVal address, value, 1End Sub’ write an integer into memorySub PokeI(ByVal address As Long, ByVal value As

Making Inline Functions Compatible With C Compilers

A global function may be declared inline. If you use the same function in different development environments, e.g., C and C++, you can hide the “inline” keyword from a C compiler while keeping it visible to a C++ compiler like this: #ifndef __cplusplus#define inline#endif The preprocessor directives make sure that

No more posts to show