January 12th, 2004, 03:49 AM
I'm tring to use the MFC CRegKey
I get a warining about the SetValue with the 2 parameters that is is depricated, so I guess I have to use the setValue with the 4 parameters
I have 3 question about the SetValue with the 4 parameters
1. how do I set a DWORD?
2. Do I need to use open first?
3. Can anyone show me an example for the use of SetValue with 4 parameters?
January 12th, 2004, 04:01 AM
see this FAQ for a startup and adapt it to your needs.
January 12th, 2004, 04:08 AM
I have looked at this FAQ before posting this thread
I have used this sample, but I get a compliation error about SetValue is being deprecated
here is the warning:
d:\Projects\Registry\Registry.cpp(170): warning C4996: 'ATL::CRegKey::SetValue' was declared deprecated
I saw that there are a few SetValue fucctions and only the one with the 4 parameters is not deprecated, but I don't know how to use it (specally for DWORD)
January 12th, 2004, 04:37 AM
Instead of CRegKey::SetValue deprecated functions, use
January 12th, 2004, 05:29 AM
that's exactly what I needed.
April 23rd, 2013, 12:02 PM
Sorry to revive an old thread. I inherited old code that needs updating into VS2010 and I'm not very familiar with C++. At all. So I apologize for asking painfully obvious questions. :-)
Here's what I have
where CString DataPath = "D:\\"
I see that I'm supposed to use "SetDWORDValue" or something similar, but I'm not seeing a solution which explicitly stores data to the specified HKEY. Do I need to set it up somewhere else? Is it not necessary?
There are a ton of these 'superseded' commands to update, I'm not completely sure how to translate them into the new commands.
Thanks for your help! I really appreciate it.
April 23rd, 2013, 01:00 PM
You should be very careful with writing to HKEY_LOCAL_MACHINE. It is not allowed for users withot Admin rights.
Originally Posted by Grue42
April 23rd, 2013, 12:18 PM
Just look for the appropriate overloaded CRegKey method in msdn.
In the case above, you aren't going to use the SetDWORDValue method since you aren't setting a DWORD value (i.e. "D:\\" isn't a DWORD).
April 23rd, 2013, 01:44 PM
Thank you for the advice VictorN - this software comes pre-installed on computers so the users are setup with admin rights. It's a necessary evil.
I can about put a button on a panel and make it do a simple task. I'm *very* new to this. The idea was that updating this existing software would be a good way to learn...
Thank you Arjay. I found this previously: http://technet.microsoft.com/en-us/s.../xka57xy4.aspx and tried to match what SetValue did - but didn't find anything with matching parameters including the hKeyParent except maybe CSettingsStore if I can/should use it in conjunction with something else?
I feel a bit stupid for not being able to extrapolate this to a new command, but I seem to just be going in circles. Can anyone help with a specific example?
Maybe I should have specified that
Again, thank you all for your patient help and advice!
April 23rd, 2013, 01:59 PM
Perhaps, something like (just a pseudo code!)
key.SetKeyValue(_T("Software\\afolder\\somefolder"), DataPath, _T("DataPath"));
April 23rd, 2013, 03:34 PM
Originally Posted by VictorN
April 23rd, 2013, 05:07 PM
That did it - perfect. I didn't realize I could specify the CRegKey like that.
Thank you all very much! I really appreciate the help!
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.