UnlockString - Retrieve and release a string locked to memory with LockString

Top  Previous  Next

Syntax

 

<cString> := UnlockString( <nAddress> )

 

Parameters

 

<nAddress>

 

Address of allocated memory block that was returned by LockString or LockNullString.

 

Return value

 

String found at <nAddress>.

 

Description

 

UnlockString returns the data found in memory at address <nAddress> as a string. After reading it, the allocated memory block is released and <nAddress> becomes invalid. Use UnlockString only with memory addresses that were returned by LockString or LockNullString.

 

If the locked string is of type STRINGTYPE_TEXT, STRINGTYPE_UNICODETEXT or STRINGTYPE_BINARY0, only the characters up to and not including the string terminator are read.

 

Classification

 

Core

 

Category

 

Pointers and Memory

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

See also

 

LockString, LockNullString, ReadLockString, ReleaseLockString

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

 

FUNCTION Main

 

LOCAL address

 

* Allocate memory and fill it with zeroes

address := LockNullString(4)

 

* Read the string as long, 0 should be the result

? PeekLong( address )

 

* Write "Beer" to the allocated memory block

PokeLong( address, Bin2L("Beer") )

 

* Read the locked string, release the allocated memory and output the string

? UnlockString( address )

 

RETURN NIL