| 327 | } |
| 328 | |
| 329 | std::vector<std::string> KeyHandler::GetValueNames() |
| 330 | { |
| 331 | LSTATUS status; |
| 332 | DWORD maxSize; |
| 333 | // pick-up maximum size for value names |
| 334 | if ((status = RegQueryInfoKeyW( |
| 335 | this->Handler, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
| 336 | nullptr, &maxSize, nullptr, nullptr, nullptr)) != ERROR_SUCCESS) { |
| 337 | throw registry_error(this->FormatSystemError(status)); |
| 338 | } |
| 339 | // increment size for final null |
| 340 | auto data = cm::make_unique<wchar_t[]>(++maxSize); |
| 341 | DWORD index = 0; |
| 342 | DWORD size = maxSize; |
| 343 | |
| 344 | std::vector<std::string> valueNames; |
| 345 | |
| 346 | while ((status = RegEnumValueW(this->Handler, index, data.get(), &size, |
| 347 | nullptr, nullptr, nullptr, nullptr)) == |
| 348 | ERROR_SUCCESS) { |
| 349 | auto name = this->ToNarrow(data.get()); |
| 350 | valueNames.push_back(name.empty() ? "(default)" : name); |
| 351 | size = maxSize; |
| 352 | ++index; |
| 353 | } |
| 354 | |
| 355 | if (status != ERROR_NO_MORE_ITEMS) { |
| 356 | throw registry_error(this->FormatSystemError(status)); |
| 357 | } |
| 358 | |
| 359 | return valueNames; |
| 360 | } |
| 361 | |
| 362 | std::vector<std::string> KeyHandler::GetSubKeys() |
| 363 | { |
no test coverage detected