Skip to content

Reg_Enum_Value

Obsolete

This command is obsolete. Use the cRegistry class for accessing the Windows Registry in DataFlex.

Purpose

Allows for enumeration of the values of a registry subkey.

Syntax

Reg_Enum_Value hKey

What It Does

Reg_Enum_Value enumerates the values of a registry subkey. 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_Value.

The function Reg_String_Value_Enum will be sent for every string value of the given key, hKey, and Reg_Integer_Value_Enum will be sent for every other value of the given subkey. Returning the value 0 from the function Reg_Key_Enum will stop the enumeration. A non-zero value will continue enumeration.

hKey must be a handle of a valid registry key. Use Reg_Open_Key to obtain the handle of the registry key. You may also use Reg_Enum_Key to obtain subkey handles.

Example

Procedure OnClick
End_Procedure

Object oRegistryEnumeration Is A cArray
    Property Integer piValueCount

    Function Reg_String_Value_Enum String sSubKeyName String sData Returns Integer
        Integer iValueCount
        Get piValueCount to iValueCount
        Showln "String Value name: " sSubKeyName " It's Data: [" sData "]"
        Set piValueCount to (iValueCount + 1)
        Function_Return 1  // continue with this pass of enumeration.
    End_Function

    Function Reg_Integer_Value_Enum String sSubKeyName Integer iValue Returns Integer
        Integer iValueCount
        Get piValueCount to iValueCount
        Showln "Integer Value name: " sSubKeyName " It's Data: [" iValue "]"
        Set piValueCount to (iValueCount + 1)
        Function_Return 1  // continue with this pass of enumeration.
    End_Function

    Procedure Test
        Handle hKey
        // Reset counter.
        Set piValueCount to 0
        Move (OpenCurrentConfigKey(current_object, "Display\Fonts")) 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_Value hKey  // Enumerate, but do not recurse.
            Reg_Close_Key hKey
        End
        Else 
            Showln "Reg_Open_Key failed!"

        Function_Return (piValueCount(Self))
    End_Procedure
End_Object