GetSubkeys - cRegistry
Retrieves the names of all Subkeys belonging to the open Key
Type: Function
Return Data Type: Integer
Parameters
| Parameter | Type | Description |
|---|---|---|
| hoArray | Handle | An object-handle of an Array-based object to receive the names of the SubKeys |
Syntax
Function GetSubkeys Handle hoArray Returns Integer
Call Example
Get GetSubkeys hoArray to IntegerVariable
Description
The GetSubkeys function populates an array with the names of the the Subkeys of the Key that is presently open. You pass the handle of an array-based object that you want the names appended to. Upon returning from the method, each Subkey name is stored in individual items in the array. The array is not cleared before the names are appended.
Sample
In this sample, the names of all subkeys belonging to the "SOFTWARE\Data Access Worldwide" Key are displayed. First the Key is opened, and then an Array object is created to store the names. The object-handle of this array is passed to GetSubKeys, which returns the number of Subkeys that was added to the array. The contents of the array are then displayed, before finally deleting the array object that we created.
Use cRegistry.pkg
Object oRegistry is a cRegistry
Procedure DoShowSubkeys
Boolean bOpened
Handle hoArray
Integer iSubkey iNumSubkeys
// Open the Key...
Get OpenKey "Software\Data Access Worldwide" To bOpened
If bOpened Begin
// create an array to store the names...
Get Create U_Array To hoArray
Get GetSubkeys hoArray To iNumSubkeys
Showln 'Number of Subkeys =' iNumSubkeys
For iSubkey from 0 To (iNumSubkeys -1)
Showln iSubkey ' ' (Value(hoArray, iSubkey))
Loop
// destroy the array, as it is not needed anymore...
Send Destroy of hoArray
Send CloseKey // must close all open Keys
End
End_Procedure
End_Object
Send DoShowSubkeys of oRegistry
| Col 1 | Col 2 |
|---|---|
| Note: | To use this function on Windows Vista, if you have changed pfAccessRights from it's default setting, pfAccessRights must contain the flag KEY_ENUMERATE_SUB_KEYS. |
See Also
Return Value
The return value is the number of Subkeys that were added to the array