 |
|
 |
Hi and congratulation for your code!
I'd liek to know if it's possible (and how to do it) to write into the registry a 'masked Value Data'.I'd like infact to save in the registry a password but of course I don't want someone else to see it cleary!
is ti possible to show it to the registry as an...asterisk array (*****) or to hide it?!?!
Thanks a lot.
SB
|
|
|
|
 |
|
 |
Thank you for such a simple and elegant class that gets the job done.
Again, thanks, appreciate it.
|
|
|
|
 |
|
 |
I need to write/read settings in the registry.
I should use this class, it seems very useful. But i need to save in another key rather than ../Software/<company>/<application>, because I need to share info between 2 apps.
Can I do this with this class?
|
|
|
|
 |
|
 |
If you need to read "other app" values, then just use the "SetRegistryKey" call to swap the context before you call "GetProfile..." or "WriteProfile...". If you need something more complicated such as storage in a different part of the HKLM registry, then you are better of using a generic registry class such as the one in ATL, coding directly to the SDK, or one of the many wrapper classes for the registry here on codeproject.
Regards,
|
|
|
|
 |
|
 |
Nice class - simple & clean. Here are 2 extra calls to handle floating point numbers. They are 4 bytes, so they are handled just like the "int" calls! Enjoy.
float CHKLM::GetProfileFloat(LPCTSTR lpszSection, LPCTSTR lpszEntry, float fDefault)
{
ASSERT(lpszSection != NULL);
ASSERT(lpszEntry != NULL);
HKEY hSecKey = GetSectionKey(lpszSection);
if (hSecKey == NULL)
return fDefault;
DWORD dwValue;
float fValue = 1.0f;
DWORD dwType;
DWORD dwCount = sizeof(float);
LONG lResult = RegQueryValueEx(hSecKey, (LPTSTR)lpszEntry, NULL, &dwType,
(LPBYTE)&fValue, &dwCount);
RegCloseKey(hSecKey);
if (lResult == ERROR_SUCCESS)
{
ASSERT(dwType == REG_DWORD);
ASSERT(dwCount == sizeof(float));
return (float)fValue;
}
return fDefault;
}
BOOL CHKLM::WriteProfileFloat(LPCTSTR lpszSection, LPCTSTR lpszEntry, float fValue)
{
ASSERT(lpszSection != NULL);
ASSERT(lpszEntry != NULL);
HKEY hSecKey = GetSectionKey(lpszSection);
if (hSecKey == NULL)
return FALSE;
LONG lResult = RegSetValueEx(hSecKey, lpszEntry, NULL, REG_DWORD,
(LPBYTE)&fValue, sizeof(float));
RegCloseKey(hSecKey);
return lResult == ERROR_SUCCESS;
}
- Carlos
|
|
|
|
 |
|
 |
The class fails to read any key that is readonly. This is a problem since Win2000 defaults access to HKLM for "normal" users to readonly.
|
|
|
|
 |
|
 |
The latest version on my web site (www.naughter.com) has a fix for this.
|
|
|
|
 |
|
 |
..and therefore very useful. thank you
|
|
|
|
 |
|
 |
I totaly agree! Brilliant sollution, recreating a familiar interface to do the same Visual C usually does, only in a way you want it to do it.
Thanks a lot! This saved me a lot of time.
|
|
|
|
 |
|
 |
there are no security related code to all user use the created key, there are a lot of stuff missin
|
|
|
|
 |
|
 |
Great, really constructive feedback. If you do not want to use it and prefer to use the SDK functions then so be it, but why trash my code when you do not bother to suggest the details of what's wrong with it
|
|
|
|
 |
|
 |
And what about CRegKey. This class implements access to HKEY_LOCAL_MACHINE also. I tested this on NT 4.0 machine without any problems
|
|
|
|
 |
|
 |
My class is designed so that people who are currently using the CWinApp registry functions can use my class/functions without having to know the details of the registry. If you want to do more advanced things such as storing REG_EXPAND_SZ or REG_MULTI_SZ then a registry wrapper class such as CRegKey is more appropiate, but 99% of the usage of the registry I have ever done is to write simple strings or ints to your applications part of the registry and for this CHKLM is ideal
|
|
|
|
 |