Usage
Writes a string to memory. Not available in WinTask Lite.
Syntax
PokeString(<address>, <string>[, <term> [, Unicode]])
or
ret = PokeString(<address>, <string>[, <term> [, Unicode]])
Parameters
<address>
: UNSIGNED, address to which<string>
is written.<term>
: number, to indicate if an end of string character must be added.- 0: no character is added
- 1: a binary zero is added (default value)
- 2: two binary zeroes are added
- Unicode: optional keyword. It tells that the string to write to memory is written using Unicode encoding.
Return value
ret
: numeric return code. When <string>
has been written successfully, the function returns 0, otherwise use this return code for Error Handling.
Example
dim Memptr as unsigned
Memptr = 32500
ret = PokeString(MemPtr, "My string", 1)
Example Code
'memory address
dim pointer as unsigned
'memory allocation
pointer = allocate(64)
'prepare a variable for the return value
wdir$ = " "
'write the blank string to memory
ret = PokeString(pointer, wdir$, 0)
'In Win32, an A must be added to functions returning an ASCII string
a = External("kernel32", "GetWindowsDirectoryA", pointer, 64)
'read the string at the given memory address
var$ = PeekString$(pointer)
msgbox(var$)