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

Method Execute

WinArk/CopyValueCommand.cpp:10–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8}
9
10bool CopyValueCommand::Execute() {
11 auto key = Registry::OpenKey(GetPath(), KEY_QUERY_VALUE);
12 if (!key)
13 return false;
14
15 auto target = Registry::OpenKey(_targetPath, KEY_WRITE | KEY_READ);
16 if (!target)
17 return false;
18
19 DWORD size;
20 int i = 1;
21 auto tname = GetName();
22 LSTATUS error;
23 while (ERROR_SUCCESS == (error = target.QueryValue(tname, nullptr, nullptr, &size))) {
24 // value already exists
25 if (i++ == 1)
26 tname = "Copy Of " + _name;
27 else
28 tname.Format(L"Copy(%d) Of %s", i, _name);
29 }
30 if (error != ERROR_FILE_NOT_FOUND) {
31 ::SetLastError(error);
32 return false;
33 }
34 _targetName = tname;
35
36 if (!Registry::CopyValue(key.Get(), target.Get(), GetName(), _targetName))
37 return false;
38
39 return InvokeCallback(true);
40}
41
42bool CopyValueCommand::Undo() {
43 auto target = Registry::OpenKey(_targetPath, KEY_WRITE);

Callers

nothing calls this directly

Calls 2

QueryValueMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected