forked from coddec/Classic-Shell
- Notifications
You must be signed in to change notification settings - Fork 452
/
Copy pathLegacy.cpp
41 lines (35 loc) · 1.47 KB
/
Legacy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include"stdafx.h"
#include<filesystem>
namespacefs= std::filesystem;
staticvoidCopyRegKey(HKEY root, constwchar_t* srcKey, constwchar_t* dstKey)
{
CRegKey src;
if (src.Open(root, srcKey, KEY_READ | KEY_WOW64_64KEY) == ERROR_SUCCESS)
{
CRegKey dst;
if (dst.Create(root, dstKey, nullptr, 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, nullptr, nullptr) == ERROR_SUCCESS)
::RegCopyTree(src, nullptr, dst);
}
}
staticvoidCopyFolder(constwchar_t* srcPath, constwchar_t* dstPath)
{
wchar_t src[MAX_PATH]{};
::ExpandEnvironmentStrings(srcPath, src, _countof(src));
wchar_t dst[MAX_PATH]{};
::ExpandEnvironmentStrings(dstPath, dst, _countof(dst));
std::error_code err;
fs::copy(src, dst, fs::copy_options::recursive | fs::copy_options::update_existing, err);
}
voidImportLegacyData()
{
CRegKey reg;
if (reg.Open(HKEY_CURRENT_USER, L"Software\\OpenShell", KEY_READ | KEY_WOW64_64KEY) == ERROR_FILE_NOT_FOUND)
{
CopyRegKey(HKEY_CURRENT_USER, L"Software\\IvoSoft\\ClassicExplorer", L"Software\\OpenShell\\ClassicExplorer");
CopyRegKey(HKEY_CURRENT_USER, L"Software\\IvoSoft\\ClassicIE", L"Software\\OpenShell\\ClassicIE");
CopyRegKey(HKEY_CURRENT_USER, L"Software\\IvoSoft\\ClassicShell", L"Software\\OpenShell\\OpenShell");
CopyRegKey(HKEY_CURRENT_USER, L"Software\\IvoSoft\\ClassicStartMenu", L"Software\\OpenShell\\StartMenu");
CopyFolder(L"%APPDATA%\\ClassicShell", L"%APPDATA%\\OpenShell");
CopyFolder(L"%LOCALAPPDATA%\\ClassicShell", L"%LOCALAPPDATA%\\OpenShell");
}
}