-
January 12th, 2004, 03:49 AM
#1
CRegKey::SetValue
Hello,
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?
thanks
avi
-
January 12th, 2004, 04:01 AM
#2
see this FAQ for a startup and adapt it to your needs.
-
January 12th, 2004, 04:08 AM
#3
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)
thanks again
avi
-
January 12th, 2004, 04:37 AM
#4
Instead of CRegKey::SetValue deprecated functions, use
CRegKey::SetDWORDValue or
CRegKey::SetStringValue or
CRegKey::SetMultiStringValue.
-
January 12th, 2004, 05:29 AM
#5
thanks
that's exactly what I needed.
avi
-
April 23rd, 2013, 11:02 AM
#6
Re: CRegKey::SetValue
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
Code:
key.SetValue(HKEY_LOCAL_MACHINE, "Software\\afolder\\somefolder",DataPath,"DataPath");
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, 11:18 AM
#7
Re: CRegKey::SetValue
Just look for the appropriate overloaded CRegKey method in msdn.
http://msdn.microsoft.com/en-us/libr...v=vs.100).aspx
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, 12:00 PM
#8
Re: CRegKey::SetValue
Originally Posted by Grue42
Here's what I have
Code:
key.SetValue(HKEY_LOCAL_MACHINE, "Software\\afolder\\somefolder",DataPath,"DataPath");
where CString DataPath = "D:\\"
You should be very careful with writing to HKEY_LOCAL_MACHINE. It is not allowed for users withot Admin rights.
Victor Nijegorodov
-
April 23rd, 2013, 12:44 PM
#9
Re: CRegKey::SetValue
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
CRegKey key;
Again, thank you all for your patient help and advice!
-
April 23rd, 2013, 12:59 PM
#10
Re: CRegKey::SetValue
Perhaps, something like (just a pseudo code!)
Code:
CRegKey key(HKEY_LOCAL_MACHINE);
key.SetKeyValue(_T("Software\\afolder\\somefolder"), DataPath, _T("DataPath"));
Victor Nijegorodov
-
April 23rd, 2013, 02:34 PM
#11
Re: CRegKey::SetValue
Originally Posted by VictorN
Perhaps, something like (just a pseudo code!)
Code:
CRegKey key(HKEY_LOCAL_MACHINE);
key.SetKeyValue(_T("Software\\afolder\\somefolder"), DataPath, _T("DataPath"));
Exactly
-
April 23rd, 2013, 04:07 PM
#12
Re: CRegKey::SetValue
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!
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
|