Je crée la clé de Registre en utilisant le code suivant:Comment lire la clé de Registre Valeur
LPCTSTR lpNDS= TEXT("SOFTWARE\\myKEY");
if(OK==ERROR_SUCCESS)
{
MessageBox (NULL, "Success",
_T("SimpleShlExt"),
MB_ICONINFORMATION);
}
else
{
MessageBox (NULL, "Failed" ,
_T("SimpleShlExt"),
MB_ICONINFORMATION);
}
LONG openRes = RegCreateKeyEx(
HKEY_LOCAL_MACHINE,
lpNDS,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hRegKey,
NULL);
if (openRes!=ERROR_SUCCESS)
MessageBox (NULL, "Registry Createion Failed",
_T("SimpleShlExt"),
MB_ICONINFORMATION);
Maintenant, je vous écris à la clé en utilisant:
CSimpleShlExt::WriteToRegistry(LPSTR lpRegKeyVal)
{
LONG setRes = RegSetValueEx (hRegKey, "NDS", 0, REG_SZ, (LPBYTE)lpRegKeyVal, strlen(lpRegKeyVal)+1);
CloseRegistryKey();
}
Maintenant, je suis en train de lire le valeur de clé de registre que j'ai créée en utilisant la fonction WriteToRegistry
. J'ai essayé avec
RegOpenKeyEx(hRegKey,lpNDS,0,KEY_QUERY_VALUE,&hRegKey);
Mais ceci échoue.
Quelle fonction dois-je utiliser pour lire la valeur contenue dans la clé?
maintenant Comment puis-je obtenir la valeur du RegistryKey, dans mon cas, J'écris de la valeur à NDS. * lpStorage est un entier.Désolé pour être si simple, mais je suis juste nouveau à ce – Simsons
Petite édition qui a fonctionné pour moi et peut être mise à jour en réponse: – Simsons
if (ERROR_SUCCESS == RegQueryValueEx (hRegKey, _T ("NDS"), 0, 0, (BYTE *) szValue, & dwBufSize)) \t \t \t \t \t \t { \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t MessageBox (NULL, szValue, \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t _T ("Value"), \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t MB_ICONINFORMATION); \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t} – Simsons