mirror of
https://github.com/Open-Shell/Open-Shell-Menu.git
synced 2026-04-11 17:37:22 +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:
41
Src/StartMenu/Legacy.cpp
Normal file
41
Src/StartMenu/Legacy.cpp
Normal 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");
|
||||
}
|
||||
}
|
||||
2
Src/StartMenu/Legacy.h
Normal file
2
Src/StartMenu/Legacy.h
Normal file
@@ -0,0 +1,2 @@
|
||||
// import legacy Classic Shell settings/data if we don't have any yet
|
||||
void ImportLegacyData();
|
||||
@@ -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)<WIN_VER_WIN8))
|
||||
|
||||
@@ -271,6 +271,7 @@
|
||||
<Text Include="..\Localization\English\MenuADMX.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Legacy.cpp" />
|
||||
<ClCompile Include="StartMenu.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
@@ -283,6 +284,7 @@
|
||||
<ResourceCompile Include="StartMenu.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Legacy.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
@@ -359,4 +361,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user