Import legacy Classic Shell data (#28)

Copy data/settings from legacy Classic Shell if we don't have any yet.
This commit is contained in:
ge0rdi
2018-08-12 01:17:59 +02:00
committed by ge0rdi
parent c350b0c037
commit 07a5a7ba72
4 changed files with 50 additions and 1 deletions
+41
View File
@@ -0,0 +1,41 @@
#include "stdafx.h"
#include <filesystem>
namespace fs = std::experimental::filesystem;
static void CopyRegKey(HKEY root, const wchar_t* srcKey, const wchar_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);
}
}
static void CopyFolder(const wchar_t* srcPath, const wchar_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);
}
void ImportLegacyData()
{
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");
}
}