Share via


RegistryGetDWORD

Send Feedback

This function reads REG_DWORD registry values.

HRESULT WINAPI RegistryGetDWORD( 
  HKEY hKey,
  LPCTSTR pszSubKey,
  LPCTSTR pszValueName,
  DWORD* pdwData
);

Parameters

  • hKey
    [in] Handle to the open key or a predefined root value.
  • pszSubKey
    [in] Key where the value is stored. If this value is NULL, then pszValueName is assumed to be under hkey.
  • pszValueName
    [in] Named value to retrieve. If this value is NULL, the function retrieves the default value.
  • pdwData
    [out] A pointer to the buffer that will receive the data.

Return Values

The following table shows the return values for this function.

Value Description
S_OK Data is copied to the buffer.
E_INVALIDARG Invalid hkey or pdwData.
E_DATATYPE_MISMATCH The value is not type REG_DWORD.
An error value returned by RegOpenKey or RegQueryValueEx. Error value wrapped as a FACILITY_WIN32 HRESULT.

Remarks

Success indicates that the value is copied to the buffer pointed to by pdwData. Failure does not cause any change.

The header file snapi.h contains definitions for the registry keys, paths, values, and bitmasks for all the base notifications that are provided by the system.

If the key pointed to by hkey and pszSubkey does not exist, the function fails.

Code Example

The following code example demonstrates how to use RegistryGetDWORD.

Note   To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.

DWORD GetNumberOfBlueToothConnections()
{

    DWORD cBluetoothConnections = 0;
    HRESULT hr;

    hr = RegistryGetDWORD(SN_CONNECTIONSBLUETOOTHCOUNT_ROOT, 
                          SN_CONNECTIONSBLUETOOTHCOUNT_PATH, 
                          SN_CONNECTIONSBLUETOOTHCOUNT_VALUE, 
                          &cBluetoothConnections);

    if (SUCCEEDED(hr))
        return cBluetoothConnections;

    else
        return 0;

}

Requirements

Pocket PC: Windows Mobile 5.0 and later.
Smartphone: Windows Mobile 5.0 and later.
OS Versions: Windows CE 5.01 and later.
Header: Regext.h
Link Library: Aygshell.lib

See Also

State and Notifications Broker Functions | State and Notifications Broker Reference | State and Notifications Broker | Using the State and Notifications Broker in Native Code

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.