| 7 | } |
| 8 | |
| 9 | bool DeleteValueCommand::Execute() { |
| 10 | auto key = Registry::OpenKey(GetPath(), KEY_WRITE | KEY_READ); |
| 11 | if (!key) |
| 12 | return false; |
| 13 | _size = 0; |
| 14 | auto error = key.QueryValue(GetName(), &_type, nullptr, &_size); |
| 15 | ::SetLastError(error); |
| 16 | if (error != ERROR_SUCCESS) |
| 17 | return false; |
| 18 | |
| 19 | if (_size) { |
| 20 | _data = std::make_unique<BYTE[]>(_size); |
| 21 | if (!_data) { |
| 22 | ::SetLastError(ERROR_OUTOFMEMORY); |
| 23 | return false; |
| 24 | } |
| 25 | error = key.QueryValue(GetName(), &_type, _data.get(), &_size); |
| 26 | ::SetLastError(error); |
| 27 | if (ERROR_SUCCESS != error) |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | error = key.DeleteValue(GetName()); |
| 32 | ::SetLastError(error); |
| 33 | if (ERROR_SUCCESS != error) |
| 34 | return false; |
| 35 | |
| 36 | return InvokeCallback(true); |
| 37 | } |
| 38 | |
| 39 | bool DeleteValueCommand::Undo() { |
| 40 | auto key = Registry::OpenKey(GetPath(), KEY_WRITE); |
nothing calls this directly
no test coverage detected