ValueLength - cRegistry
Returns the length of the data for a named Value of the currently open Key
Type: Function
Return Data Type: Integer
Parameters
| Parameter | Type | Description |
|---|---|---|
| sValueName | String | The name of the Value to obtain the size of the data from |
Syntax
Function ValueLength String sValueName Returns Integer
Call Example
Get ValueLength sValueName to IntegerVariable
Description
Use ValueLength to determine the number of bytes stored for a specific Value.
A common reason to need to know the data length is when you need to dynamically allocate memory for loading binary data, as this example shows.
Use cRegistry.pkg
Object oRegistry is a cRegistry
Procedure DoShowValueDataLength
Boolean bSuccess
String sKey sWindowPlacement
Integer iDataLength
Address aWindowPlacement
Move "Software\Data Access Worldwide\Examples\Contact\8.0;
\Contact\Windows\Contacts" To sKey
Get OpenKey sKey To bSuccess
If bSuccess Begin
Get ValueLength "Placement" To iDataLength
Showln "Data length=" iDataLength
// Prepare memory to read the binary data into...
ZeroString iDataLength To sWindowPlacement
// and get its memory address...
Move (AddressOf(sWindowPlacement)) To aWindowPlacement
// read the binary data and store it at the address of the string...
Get ReadBinary "Placement" aWindowPlacement iDataLength To bSuccess
// must close Keys that we open...
Send CloseKey
End
Else Showln 'Cannot open Key'
End_Procedure
End_Object
Send DoShowValueDataLength of oRegistry
See Also
Return Value
The number of bytes of data held in the Value.