枚举注册表Key 枚举注册表Value

#include <iostream> #include <windows.h> using namespace std; void main(int argc,char*argv[]) { HKEY hKey = NULL; if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE//Microsoft//Windows NT//CurrentVersion//Drivers32",0,KEY_ALL_ACCESS,&hKey)) return; /***********************枚举注册表Key****************************/ /*DWORD dwSubKeyCount = 0; if(ERROR_SUCCESS != RegQueryInfoKey(hKey,NULL,NULL,NULL,&dwSubKeyCount,NULL,NULL,NULL,NULL,NULL,NULL,NULL)) { RegCloseKey(hKey); return; } DWORD dwIndex = 0; CHAR szName[MAX_PATH] = {0}; DWORD dwNameLen = MAX_PATH; for (;dwIndex<dwSubKeyCount;dwIndex++) { if(ERROR_SUCCESS == RegEnumKey(hKey,dwIndex,szName,dwNameLen)) cout<<szName<<endl; }*/ /***********************枚举注册表Key****************************/ long lResult = 0; CHAR szName[MAX_PATH] = {0}; DWORD dwNameLen = MAX_PATH; DWORD dwIndex = 0; lResult = RegEnumKey(hKey,dwIndex,szName,dwNameLen); while(ERROR_SUCCESS == lResult) { cout<<szName<<endl; dwIndex++; lResult = RegEnumKey(hKey,dwIndex,szName,dwNameLen); } /***********************枚举注册表Value****************************/ /*long lResult = 0; CHAR szName[MAX_PATH] = {0}; DWORD dwNameLen = MAX_PATH; DWORD dwType = REG_SZ; BYTE bValue[MAX_PATH] = {0}; DWORD dwValueLen = MAX_PATH; DWORD dwIndex = 0; lResult = RegEnumValue(hKey,dwIndex,szName,&dwNameLen,NULL,&dwType,bValue,&dwValueLen); while(ERROR_SUCCESS == lResult && REG_SZ == dwType && bValue) { cout<<szName<<" "<<dwNameLen<<" "<<bValue<<" "<<dwValueLen<<endl; dwIndex++; dwNameLen = MAX_PATH; dwValueLen = MAX_PATH; lResult = RegEnumValue(hKey,dwIndex,szName,&dwNameLen,NULL,&dwType,bValue,&dwValueLen); }*/ RegCloseKey(hKey); }

你可能感兴趣的:(枚举注册表Key 枚举注册表Value)