diff --git a/Src/StartMenu/Legacy.cpp b/Src/StartMenu/Legacy.cpp new file mode 100644 index 0000000..b8fa294 --- /dev/null +++ b/Src/StartMenu/Legacy.cpp @@ -0,0 +1,41 @@ +#include "stdafx.h" +#include +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"); + } +} diff --git a/Src/StartMenu/Legacy.h b/Src/StartMenu/Legacy.h new file mode 100644 index 0000000..dea506d --- /dev/null +++ b/Src/StartMenu/Legacy.h @@ -0,0 +1,2 @@ +// import legacy Classic Shell settings/data if we don't have any yet +void ImportLegacyData(); diff --git a/Src/StartMenu/StartMenu.cpp b/Src/StartMenu/StartMenu.cpp index 6f286f6..b9dc341 100644 --- a/Src/StartMenu/StartMenu.cpp +++ b/Src/StartMenu/StartMenu.cpp @@ -11,6 +11,7 @@ #include "ComHelper.h" #include "Settings.h" #include "psapi.h" +#include "Legacy.h" #include "StartMenuDLL\StartMenuDLL.h" #include "StartMenuDLL\SettingsUI.h" @@ -335,6 +336,9 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC } }*/ + // one-time import from Classic Shell + ImportLegacyData(); + DllLogToFile(STARTUP_LOG,L"StartMenu: start '%s'",lpstrCmdLine); DWORD winVer=GetVersionEx(GetModuleHandle(L"user32.dll")); if (wcsstr(lpstrCmdLine,L"-startup") || (wcsstr(lpstrCmdLine,L"-autorun") && HIWORD(winVer) + Create @@ -283,6 +284,7 @@ + @@ -359,4 +361,4 @@ - + \ No newline at end of file