1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| // Read the REG_MULTI_SZ values - Get size of the buffer for the values
returnStatus = RegQueryValueExA(hKey, "NomChamp", NULL, NULL, NULL, &dwSize);
if(returnStatus != ERROR_SUCCESS)
{
printf("Error reading the registry key");
exit(1);
}
try { regValue = new char[dwSize+1]; }
catch(bad_alloc &ba) { printf("bad_alloc caught: %s\n", ba.what()); exit(EXIT_FAILURE); }
// Get the values
returnStatus = RegQueryValueExA(hKey, "NomChamp", NULL, NULL, (LPBYTE)regValue, &dwSize);
if(returnStatus != ERROR_SUCCESS)
{
printf("Error getting the values of the registry key");
exit(3);
}
// Put the values into the returnValues vector
for(; *regValue != '\0'; regValue += strlen(regValue)+1)
{
char* itemValue = NULL;
try { itemValue = new char[strlen(regValue)+1]; }
catch(bad_alloc &ba) { printf("bad_alloc caught: %s\n", ba.what()); exit(EXIT_FAILURE); }
strcpy(itemValue, regValue);
returnValues.push_back(itemValue);
}
if(hKey) RegCloseKey(hKey);
if(regValue) delete[] regValue; // SEGFAULT précisément ici.
return returnValues; |
Partager