Skip to content

ValueType - cRegistry

Returns the data type for the 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 type of the data from

Syntax

Function ValueType String sValueName Returns Integer

Call Example

Get ValueType sValueName to IntegerVariable

Description

Use the ValueType method to determine the data-type of an existing Value in the Key that you currently have open.

The return value can be one of the following constants:

Constant Meaning
rdString Indicates that the registry type is a string
rdDword Indicates that the registry type is a 32-bit number
rdBinary Indicates that the registry type is a binary value
rdUnknown Indicates that the registry type is unknown

Sample

This sample enumerates all the Values of a Key and shows their data type.

Use cRegistry.pkg

Object oRegistry is a cRegistry

    Procedure DoShowDataTypes
        Boolean bOpened
        Handle hoArray
        Integer iValue iNumValues
        String sValueName
        Integer eType

        // Open the Key...
        Get OpenKey "Software\MyCompany\MyProduct" To bOpened
        If bOpened Begin
            // create an array to store the names...
            Get Create U_Array To hoArray

            Get GetValues hoArray To iNumValues
            Showln 'Number of Values =' iNumValues

            For iValue from 1 To iNumValues
                Get Value of hoArray (iValue -1) To sValueName
                Show '(' iValue ') "' sValueName '" has a Data Type of: '

                Get ValueType sValueName To eType
                If (eType = rdString) Showln "String"
                Else If (eType = rdDword)   Showln "DWord"
                Else If (eType = rdBinary)  Showln "Binary"
                Else If (eType = rdUnknown) Showln "Unknown"
            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 DoShowDataTypes of oRegistry

See Also

ValueLength | ValueExists | OpenKey

Return Value

Returns an integer (constant).