|
-
October 11th, 2004, 10:10 PM
#1
RegSetValueEx not working!!!???
I am making an application that works like a windows registry
I am almost done, I can't just find out why, I got this bug which I did not encounter before. My codes has been working for the past weeks, now, it no longer works...
Help me find our why...
I created a new key:
HKEY_CURRENT_CONFIG\System\New Key #1
The key is created successfully. Then, under ...New Key #1
I created a new value, New Value #1 of type REG_SZ and no data yet.
New Value #1 is successfully created using the following codes:
Code:
CString csREG_SZ_val = "";
RegOpenKeyEx( m_hKey, csSubKey, NULL, KEY_ALL_ACCESS, &m_hSubKey );
RegSetValueEx( m_hSubKey , csValName, NULL, REG_SZ, (LPBYTE)csREG_SZ_val.GetBuffer(csREG_SZ_val.GetLength()), csREG_SZ_val.GetLength()+1);
That creates "New Value #1" of type REG_SZ under HKEY_CURRENT_CONFIG\System\New Key #1
I know that it is created because, I opened windows registry and I can see that value under that key.
Here's the BUG!!!
When I rename New Value #1 to New Value #2, it is no longer seen using RegEnumValue.
How did I rename the value? Here:
Code:
// Open the key that contains the value being renamed
RegOpenKeyEx( m_hKey, csSubKey, NULL, KEY_ALL_ACCESS, &m_hSubKey );
// Querty the name size and data size
RegQueryInfoKey( m_hSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &dwValNameSize, &dwValDataSize, NULL, NULL);
// allocate space for value data
szValData = (BYTE*)malloc(dwValDataSize+1);
// Get the type, and the data
RegQueryValueEx( m_hSubKey, csValName, &dwValNameSize, &dwType, szValData, &dwValDataSize );
// Set value using new name
RegSetValueEx( m_hSubKey, csNewValName, dwValNameSize, dwType, (CONST BYTE*)&szValData, dwValDataSize );
// Delete previous value name
RegDeleteValue( m_hSubKey, m_csValName);
After that, csNewName does not appear under HKEY_CURRENT_CONFIG\System\New Key #1!!!
Was it save somewhere else? Or it was not saved at all? I am not encountering any error messages. I said its a bug because, it is expected that the renamed value must still be present.
Please help me!!!
I am inviting you to join GreenZap. It is just like PAYPAL but it is more rewarding! You get $25 when you join (FREE to sign up) AND you get rewarded also when someone opened an account using your GreenZap promo code! GreenZap is launching June 1st.
Click here and PREREGISTER
Have a break. Visit JonelsPlace
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|