Extensions Reference

Extensions Reference > exRegistry


regGetInt

int regGetInt(string Valuename);

 

Retrieves a DWORD value from the registry as an INT type

The REGGETINT function retrieves the contents of the specified value from a previously opened registry key (opened by exRegistry::regOpenKey or exRegistry::regCreateKey). It is good practice to use exRegistry::regCheckExists to ensure the value already exists (although this is not essential).

Note: There is no "integer" registry type. This function is provided for ease of use. Integers are stored in the registry as DWORDs, this function reads a REG_DWORD value and immediately converts it to an integer for storing in a Shiny INT type variable. This is faster than reading a DWORD and using implicit type conversion. In some cases a REG_DWORD may store a value larger than an INT can accept.

Note: It is extremely important that the right function be used to retrieve the right value type from the registry. REGGETINT must only be called to obtain the contents of REG_DWORD values.

 

Parameters

Valuename

The name of the value to retrieve the contents of.

 

Return Value

The contents of the value, or -1 if the value couldn't be retrieved (for example: security permissions prevent it, the value doesn't exist etc).

 

Example Code

// Open the Brass registry key for the current user
if(regOpenKey("HKCU", "Software\\32Bits\\Brass") == True)
{
    // Retrieve an INT stored as a DWORD from the open key
    if(regCheckExists("MyRegIntVal") == TRUE)
    {
        // Read the contents of MyRegIntVal into MyVal
        int MyVal = regGetInt("MyRegIntVal");
    }

    regCloseKey();
}