Reg_Enum_Key
Obsolete
This command is obsolete. Use the cRegistry class for accessing the Windows Registry in DataFlex.
Purpose
Allows for enumeration of registry subkeys.
Syntax
Reg_Enum_Key hKey bRecursionFlag
What It Does
Reg_Enum_Key provides an easy, object-oriented mechanism for enumerating registry subkeys. To enumerate subkeys of a registry key, use Reg_Open_Key to obtain the hKey handle, assign an object to the enumeration (using Reg_Enum_Key_Info), and then invoke Reg_Enum_Key.
The function Reg_Key_Enum will be sent to the object for every subkey of the given key, hKey. The recursion flag, bRecursionFlag, allows for recursion of all levels. Returning the value 0 from the function Reg_Key_Enum will stop the enumeration. A non-zero value will continue enumeration.
hKeymust be a handle of a valid registry key. UseReg_Open_Keyto obtain the handle of the registry key.bRecursionFlagmay be either0(FALSE) or1(TRUE).
Example
Procedure OnClick
End_Procedure
Object oRegistryEnumeration Is A cArray
Property Integer piKeyCount
Function Reg_Key_Enum Integer hSubKey String sSubKeyName Returns Integer
Integer iKeyCount
Get piKeyCount to iKeyCount
Showln "Enumerating Through Registry Key: " sSubKeyName
Set piKeyCount to (iKeyCount + 1)
Function_Return 1 // continue with this pass of enumeration.
End_Function
Procedure Test
Handle hKey
// Reset counter.
Set piKeyCount to 0
Move (OpenCurrentConfigKey(current_object, "System\CurrentControlSet\Control\Print\Printers")) to hKey
if (hKey <> 0) Begin
Showln "The opened key is " hKey
// Set up enumeration so that it calls back into this object.
Reg_Enum_Key_Info (object_id(self))
// Enumerate the registry starting at hKey.
Reg_Enum_Key hKey 0 // Enumerate, but do not recurse.
Reg_Close_Key hKey
End
Else Showln "Reg_Open_Key failed!"
Function_Return (piKeyCount(Self))
End_Procedure
End_Object