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

Method Undo

WinArk/DeleteKeyCommand.cpp:36–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36bool DeleteKeyCommand::Undo() {
37 auto key = Registry::OpenKey(_path, KEY_CREATE_SUB_KEY);
38 if (!key)
39 return false;
40
41 DWORD error;
42 CRegKey keyBackup;
43 ::SetLastError(error = keyBackup.Open(HKEY_CURRENT_USER, DeletedPathBackup + _savePath, KEY_READ));
44 if (!keyBackup)
45 return false;
46
47 CRegKey newKey;
48 DWORD disp;
49 error = newKey.Create(key.Get(), _name, nullptr, 0, KEY_ALL_ACCESS, nullptr, &disp);
50 ::SetLastError(error);
51 if (error != ERROR_SUCCESS)
52 return false;
53
54 ::SetLastError(error = ::RegCopyTree(keyBackup, nullptr, newKey));
55 if (error != ERROR_SUCCESS)
56 return false;
57
58 return InvokeCallback(false);
59}

Callers

nothing calls this directly

Calls 3

OpenMethod · 0.45
CreateMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected