MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / Execute

Method Execute

WinArk/DeleteValueCommand.cpp:9–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7}
8
9bool 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
39bool DeleteValueCommand::Undo() {
40 auto key = Registry::OpenKey(GetPath(), KEY_WRITE);

Callers

nothing calls this directly

Calls 2

QueryValueMethod · 0.80
DeleteValueMethod · 0.80

Tested by

no test coverage detected