Q: How can I write data to the registry?

A:

Code:
#include <atlbase.h>

DWORD   dwValue = 245;
CRegKey RegKey;

// Open key
if(RegKey.Open(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Windows") != ERROR_SUCCESS)
  // Error handling

// Set value
if(RegKey.SetValue(dwValue, "NameOfValue") != ERROR_SUCCESS)
  // Error handling

// Close key
if(RegKey.Close() != ERROR_SUCCESS)
  // Error handling