To access the data you open the key and then query the value -
Code:
HKEY hkey;
TCHAR name[255];
TCHAR sk[] = "Software\\Microsoft\\Windows\\CurrentVersion";
DWORD a;
DWORD b;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,sk,0,KEY_QUERY_VALUE ,&hkey);
RegQueryValueEx(hkey,"Registered Owner",0,&a,(BYTE*)name,&b);
MessageBox(0,name,"Hello",0);
I think you could probably do something similar to write to data to a key using RegSetValueEx(). However you'll need to adjust the access when opening the key, and ensure the person using your program has admin rights on NT based Windows.
From your example I'd guess it'd be something like this -
Code:
TCHAR dataname[]="UserName";
TCHAR data[]="Bill Gates";
RegSetValueEx(hkey,dataname,0,REG_SZ,(BYTE*)data,strlen(data)+1);
Assuming you'd already opened the HKEY_LOCAL_MACHINE\Software\MySoftware with the required access using RegOpenKeyEx(). This is untested so you may have to changed it around to get the required result.