mirror of
https://github.com/Open-Shell/Open-Shell-Menu.git
synced 2026-06-14 03:16:38 +10:00
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:
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user