| 491 | |
| 492 | |
| 493 | LONG RegRemoveSubkeys(HKEY hRegKey) |
| 494 | { |
| 495 | // Removes all subkeys to the given key. Will not touch the given key. |
| 496 | TCHAR Name[256]; |
| 497 | DWORD dwNameSize; |
| 498 | FILETIME ftLastWrite; |
| 499 | HKEY hSubKey; |
| 500 | LONG result; |
| 501 | |
| 502 | for (;;) |
| 503 | { // infinite loop |
| 504 | dwNameSize = _countof(Name)-1; |
| 505 | if (RegEnumKeyEx(hRegKey, 0, Name, &dwNameSize, NULL, NULL, NULL, &ftLastWrite) == ERROR_NO_MORE_ITEMS) |
| 506 | return ERROR_SUCCESS; |
| 507 | result = RegOpenKeyEx(hRegKey, Name, 0, KEY_READ | g->RegView, &hSubKey); |
| 508 | if (result != ERROR_SUCCESS) |
| 509 | break; |
| 510 | result = RegRemoveSubkeys(hSubKey); |
| 511 | RegCloseKey(hSubKey); |
| 512 | if (result != ERROR_SUCCESS) |
| 513 | break; |
| 514 | result = RegDeleteKey(hRegKey, Name); |
| 515 | if (result != ERROR_SUCCESS) |
| 516 | break; |
| 517 | } |
| 518 | return result; |
| 519 | } |
| 520 | |
| 521 | |
| 522 | |