[VC++] Lecture / ecriture dans la base de registre : solution
Lecture / ecriture dans la base de registre : solution [VC++] - Programmation
Sujets relatifs:
Leave a Replay
Make sure you enter the(*)required information where indicate.HTML code is not allowed
Marsh Posté le 16-07-2001 à 18:16:44
// Ouverture de la base de registre
LPCTSTR DataBasePath;
char lpszName []= "Chemin";
HKEY hKey = 0;
HRESULT hr = RegOpenKey(HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\DivXManage" ),
&hKey);
if (hr == ERROR_SUCCESS)
{
// Lecture de la clé
TCHAR szProductType[200];
DWORD dwBufLen = 200;
RegQueryValueEx(hKey,lpszName, NULL, NULL, (LPBYTE)szProductType, &dwBufLen);
DataBasePath = szProductType;
}
else
{
DataBasePath = GetPathOfDB();
// Creation de la clé
hKey = 0;
hr = RegCreateKey(HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\DivXManage" ),
&hKey);
if (hr == ERROR_SUCCESS)
{
RegSetValueEx(hKey,
lpszName,
0,
REG_SZ,
(const BYTE*)DataBasePath,
strlen(DataBasePath));
}
}
RegCloseKey(hKey);