Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with REGISTRY

Status
Not open for further replies.

skinah

Programmer
Oct 3, 2001
17
AU
heres a function that I'm trying to write. I call the function with a line like this..

AddRegE("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\MediaResources\\AudioDSP24");

int AddRegE (char strKey[512])
{
CRegKey MyRegFix;
MyRegFix.SetKeyValue(strKey,"1","ValueCard");

return 0;

};

Why doesm't this change the key's value in my registry ? the program compiles and runs fine. Sorry if this is really simple but I have just started learning c++ , any help would be appreciated. I have a feeling it may have somthing to do with HKEY but I have no idea how to create a handle or why I need to.

Thanks Heaps,

Matt
 
I have made some headway but still dont know why my last one didn't work. This time i pass this string to the function...

AddRegE("System\\CurrentControlSet\\Control\\MediaResources\\AudioDSP24");


int AddRegE (char strKey[512])
{

HKEY root;
char szData[2];
DWORD dwBufSize = 2;

RegOpenKeyEx(HKEY_LOCAL_MACHINE, strKey, 0, KEY_ALL_ACCESS, &root);

const TCHAR szRegRoot[] = _T("System\\CurrentControlSet\\Control\\MediaResources\\AudioDSP24");

RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegRoot, 0, KEY_READ, &root);

RegSetValueEx(root, "ValueCard", 0, REG_SZ,(const BYTE*)&szData, dwBufSize);

return 0;

};


This time the value of the key is changed but as I can't set the value of szData I can't control what the value is changed to. Using the line
szData="0"; gives me an error.....

error C2106: '=' : left operand must be l-value


Please help and explain why I went wrong. I really want to learn C++ instead of just trying to understand how other ppls code works.

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top