Skip to content

Commit 07a5a7b

Browse files
committed
Import legacy Classic Shell data (#28)
Copy data/settings from legacy Classic Shell if we don't have any yet.
1 parent c350b0c commit 07a5a7b

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

Src/StartMenu/Legacy.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "stdafx.h"
2+
#include <filesystem>
3+
namespace fs = std::experimental::filesystem;
4+
5+
static void CopyRegKey(HKEY root, const wchar_t* srcKey, const wchar_t* dstKey)
6+
{
7+
CRegKey src;
8+
if (src.Open(root, srcKey, KEY_READ | KEY_WOW64_64KEY) == ERROR_SUCCESS)
9+
{
10+
CRegKey dst;
11+
if (dst.Create(root, dstKey, nullptr, 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, nullptr, nullptr) == ERROR_SUCCESS)
12+
::RegCopyTree(src, nullptr, dst);
13+
}
14+
}
15+
16+
static void CopyFolder(const wchar_t* srcPath, const wchar_t* dstPath)
17+
{
18+
wchar_t src[MAX_PATH]{};
19+
::ExpandEnvironmentStrings(srcPath, src, _countof(src));
20+
21+
wchar_t dst[MAX_PATH]{};
22+
::ExpandEnvironmentStrings(dstPath, dst, _countof(dst));
23+
24+
std::error_code err;
25+
fs::copy(src, dst, fs::copy_options::recursive | fs::copy_options::update_existing, err);
26+
}
27+
28+
void ImportLegacyData()
29+
{
30+
CRegKey reg;
31+
if (reg.Open(HKEY_CURRENT_USER, L"Software\\OpenShell", KEY_READ | KEY_WOW64_64KEY) == ERROR_FILE_NOT_FOUND)
32+
{
33+
CopyRegKey(HKEY_CURRENT_USER, L"Software\\IvoSoft\\ClassicExplorer", L"Software\\OpenShell\\ClassicExplorer");
34+
CopyRegKey(HKEY_CURRENT_USER, L"Software\\IvoSoft\\ClassicIE", L"Software\\OpenShell\\ClassicIE");
35+
CopyRegKey(HKEY_CURRENT_USER, L"Software\\IvoSoft\\ClassicShell", L"Software\\OpenShell\\OpenShell");
36+
CopyRegKey(HKEY_CURRENT_USER, L"Software\\IvoSoft\\ClassicStartMenu", L"Software\\OpenShell\\StartMenu");
37+
38+
CopyFolder(L"%APPDATA%\\ClassicShell", L"%APPDATA%\\OpenShell");
39+
CopyFolder(L"%LOCALAPPDATA%\\ClassicShell", L"%LOCALAPPDATA%\\OpenShell");
40+
}
41+
}

Src/StartMenu/Legacy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// import legacy Classic Shell settings/data if we don't have any yet
2+
void ImportLegacyData();

Src/StartMenu/StartMenu.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "ComHelper.h"
1212
#include "Settings.h"
1313
#include "psapi.h"
14+
#include "Legacy.h"
1415

1516
#include "StartMenuDLL\StartMenuDLL.h"
1617
#include "StartMenuDLL\SettingsUI.h"
@@ -335,6 +336,9 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC
335336
}
336337
}*/
337338

339+
// one-time import from Classic Shell
340+
ImportLegacyData();
341+
338342
DllLogToFile(STARTUP_LOG,L"StartMenu: start '%s'",lpstrCmdLine);
339343
DWORD winVer=GetVersionEx(GetModuleHandle(L"user32.dll"));
340344
if (wcsstr(lpstrCmdLine,L"-startup") || (wcsstr(lpstrCmdLine,L"-autorun") && HIWORD(winVer)<WIN_VER_WIN8))

Src/StartMenu/StartMenu.vcxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@
271271
<Text Include="..\Localization\English\MenuADMX.txt" />
272272
</ItemGroup>
273273
<ItemGroup>
274+
<ClCompile Include="Legacy.cpp" />
274275
<ClCompile Include="StartMenu.cpp" />
275276
<ClCompile Include="stdafx.cpp">
276277
<PrecompiledHeader>Create</PrecompiledHeader>
@@ -283,6 +284,7 @@
283284
<ResourceCompile Include="StartMenu.rc" />
284285
</ItemGroup>
285286
<ItemGroup>
287+
<ClInclude Include="Legacy.h" />
286288
<ClInclude Include="resource.h" />
287289
<ClInclude Include="stdafx.h" />
288290
<ClInclude Include="targetver.h" />
@@ -359,4 +361,4 @@
359361
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
360362
<ImportGroup Label="ExtensionTargets">
361363
</ImportGroup>
362-
</Project>
364+
</Project>

0 commit comments

Comments
 (0)