A version of this page is also available for

Windows Embedded CE 6.0 R3


This function sets a REG_DWORD registry value.


  HKEY hKey,
  LPCTSTR pszSubKey,
  LPCTSTR pszValueName,
  DWORD dwData 


  • 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 set. If this value is NULL, the function sets the default value.
  • dwData
    [in] New value.

Return Value

The following table shows the return values for this function.

Value Description


Value in pszValueName is replaced by the value in dwData.


Invalid hkey.


The value is not type REG_DWORD.

An error value returned by RegOpenKey or RegQueryValueEx.

Error value wrapped as a FACILITY_WIN32 HRESULT.


Success indicates that the old value is replaced by the new value. Failure does cause any change.

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

If the client might be calling RegistrySetDWORD multiple times, it should cache a handle to the key using RegOpenKeyEx and pass the handle instead of passing a string value. Every time RegistrySetDWORD is called with a string value for the key, the RegOpenKeyEx and RegCloseKey functions are called, so passing a handle instead of a string value can avert a potential performance problem over mutltiple calls.


Header regext.h
Library aygshell.lib
Windows Embedded CE Windows Embedded CE 6.0 and later
Windows Mobile Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

See Also


State and Notifications Broker Functions
State and Notifications Broker Reference

Other Resources

State and Notifications Broker