Extensions Reference

Extensions Reference > exRegistry


regGetDword

dword regGetDword(string Valuename);

 

Retrieves a DWORD value from the registry

The REGGETDWORD 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: It is extremely important that the right function be used to retrieve the right value type from the registry. REGGETDWORD must only be called to obtain the contents of REG_DWORD values.

Note: Boolean values can be directly read from a registry value into a Shiny type BOOL variable using implicit type conversion. This is legal and standard practice.

 

Parameters

Valuename

The name of the value to retrieve the contents of.

 

Return Value

The contents of the value, or 0x0badc0de 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 a DWORD from the open key
    if(regCheckExists("MyRegDwordVal") == TRUE)
    {
        // Read the contents of MyRegDwordVal into MyVal
        dword MyVal = regGetDword("MyRegDwordVal");
    }

    // Retrieve a boolean stored in a DWORD from the open key
    if(regCheckExists("MyBoolAsDwordVal") == TRUE)
    {
        bool MyBool = regGetDword("MyBoolAsDwordVal");
    }

    regCloseKey();
}