Base de registre et VC++

Base de registre et VC++ - C++ - Programmation

Marsh Posté le 14-04-2002 à 02:06:17    

Je n'arrive pas a acceder a ma base de registre.
G trouver les methode (ds le MSDN) mais apparament je les utilise pas comme il faut.
Quelqu'un peut me donner 1 exemple ????

Reply

Marsh Posté le 14-04-2002 à 02:06:17   

Reply

Marsh Posté le 14-04-2002 à 02:58:39    

bah, passe par la CRegKey ( #include <atlbase.h> ) ca te simplifie pas mal de boulot

Reply

Marsh Posté le 14-04-2002 à 09:24:52    

je crois qu'il faut un projet MFC alors ...

Reply

Marsh Posté le 14-04-2002 à 12:00:30    

nonske, ca marche sans, ce bout la

Reply

Marsh Posté le 14-04-2002 à 20:09:38    

Pas besoin de tout alourdir en rajoutant MFC!
Voici un exemple :
 
HKEY hMainKey;
 
unsigned long size;
unsigned long type;
 
if(RegOpenKey(HKEY_CURRENT_USER, "Software\\Product", &hMainKey) != ERROR_SUCCESS)
{
 if(RegOpenKey(HKEY_CURRENT_USER, "Software\\Product", &hMainKey) != ERROR_SUCCESS)
  return;
}
 
size = 256;
RegQueryValueEx(hMainKey, "Mp3Path", 0, &type, (unsigned char*)g_Mp3Path, &size);
 
size = 256;
RegQueryValueEx(hMainKey, "PlayerPath", 0, &type, (unsigned char*)g_PlayerPath, &size);
 
size = 256;
RegQueryValueEx(hMainKey, "FileFilter", 0, &type, (unsigned char*)g_FileFilter, &size);
 
size = 256;
RegQueryValueEx(hMainKey, "UserFilter", 0, &type, (unsigned char*)g_UserFilter, &size);
 
size = 256;
RegQueryValueEx(hMainKey, "IPFilter", 0, &type, (unsigned char*)g_IPFilter, &size);
 
size = 256;
RegQueryValueEx(hMainKey, "ServerIP", 0, &type, (unsigned char*)g_ServerIP, &size);
 
size = 4;
RegQueryValueEx(hMainKey, "Role", 0, &type, (unsigned char*)&g_Role, &size);
 
RegCloseKey(hMainKey);

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed