mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-27 16:49:08 +08:00
Drop Windows XP support
This commit is contained in:
parent
997e799138
commit
91651fc98b
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
#define USE_TASKBAR_API (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
|
#define USE_TASKBAR_API (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
|
||||||
|
|
||||||
#define XP (_WIN32_WINNT < _WIN32_WINNT_VISTA)
|
|
||||||
|
|
||||||
#define MB_TITLE L"Cmder Launcher"
|
#define MB_TITLE L"Cmder Launcher"
|
||||||
#define SHELL_MENU_REGISTRY_PATH_BACKGROUND L"Directory\\Background\\shell\\Cmder"
|
#define SHELL_MENU_REGISTRY_PATH_BACKGROUND L"Directory\\Background\\shell\\Cmder"
|
||||||
#define SHELL_MENU_REGISTRY_PATH_LISTITEM L"Directory\\shell\\Cmder"
|
#define SHELL_MENU_REGISTRY_PATH_LISTITEM L"Directory\\shell\\Cmder"
|
||||||
@ -140,7 +138,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
{
|
{
|
||||||
MessageBox(NULL,
|
MessageBox(NULL,
|
||||||
(GetLastError() == ERROR_ACCESS_DENIED)
|
(GetLastError() == ERROR_ACCESS_DENIED)
|
||||||
? L"Failed to copy ConEmu.xml file to ConEmu-%COMPUTERNAME%.xml backup location! Restart Cmder as administrator."
|
? L"Failed to copy ConEmu.xml file to ConEmu-%COMPUTERNAME%.xml backup location! Restart Cmder as Administrator."
|
||||||
: L"Failed to copy ConEmu.xml file to ConEmu-%COMPUTERNAME%.xml backup location!", MB_TITLE, MB_ICONSTOP);
|
: L"Failed to copy ConEmu.xml file to ConEmu-%COMPUTERNAME%.xml backup location!", MB_TITLE, MB_ICONSTOP);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -151,12 +149,11 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
{
|
{
|
||||||
MessageBox(NULL,
|
MessageBox(NULL,
|
||||||
(GetLastError() == ERROR_ACCESS_DENIED)
|
(GetLastError() == ERROR_ACCESS_DENIED)
|
||||||
? L"Failed to copy ConEmu-%COMPUTERNAME%.xml file to vendored ConEmu.xml location! Restart Cmder as administrator."
|
? L"Failed to copy ConEmu-%COMPUTERNAME%.xml file to vendored ConEmu.xml location! Restart Cmder as Administrator."
|
||||||
: L"Failed to copy ConEmu-%COMPUTERNAME%.xml file to vendored ConEmu.xml location!", MB_TITLE, MB_ICONSTOP);
|
: L"Failed to copy ConEmu-%COMPUTERNAME%.xml file to vendored ConEmu.xml location!", MB_TITLE, MB_ICONSTOP);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (PathFileExists(userCfgPath)) {
|
else if (PathFileExists(userCfgPath)) {
|
||||||
if (PathFileExists(cfgPath)) {
|
if (PathFileExists(cfgPath)) {
|
||||||
@ -164,7 +161,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
{
|
{
|
||||||
MessageBox(NULL,
|
MessageBox(NULL,
|
||||||
(GetLastError() == ERROR_ACCESS_DENIED)
|
(GetLastError() == ERROR_ACCESS_DENIED)
|
||||||
? L"Failed to copy ConEmu.xml file to backup location! Restart Cmder as administrator."
|
? L"Failed to copy ConEmu.xml file to backup location! Restart Cmder as Administrator."
|
||||||
: L"Failed to copy ConEmu.xml file to backup location!", MB_TITLE, MB_ICONSTOP);
|
: L"Failed to copy ConEmu.xml file to backup location!", MB_TITLE, MB_ICONSTOP);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -175,7 +172,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
{
|
{
|
||||||
MessageBox(NULL,
|
MessageBox(NULL,
|
||||||
(GetLastError() == ERROR_ACCESS_DENIED)
|
(GetLastError() == ERROR_ACCESS_DENIED)
|
||||||
? L"Failed to copy ConEmu.xml file to vendored ConEmu.xml location! Restart Cmder as administrator."
|
? L"Failed to copy ConEmu.xml file to vendored ConEmu.xml location! Restart Cmder as Administrator."
|
||||||
: L"Failed to copy ConEmu.xml file to vendored ConEmu.xml location!", MB_TITLE, MB_ICONSTOP);
|
: L"Failed to copy ConEmu.xml file to vendored ConEmu.xml location!", MB_TITLE, MB_ICONSTOP);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -186,7 +183,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
{
|
{
|
||||||
MessageBox(NULL,
|
MessageBox(NULL,
|
||||||
(GetLastError() == ERROR_ACCESS_DENIED)
|
(GetLastError() == ERROR_ACCESS_DENIED)
|
||||||
? L"Failed to copy ConEmu.xml file to user-conemu.xml backup location! Restart Cmder as administrator."
|
? L"Failed to copy ConEmu.xml file to user-conemu.xml backup location! Restart Cmder as Administrator."
|
||||||
: L"Failed to copy ConEmu.xml file to user-conemu.xml backup location!", MB_TITLE, MB_ICONSTOP);
|
: L"Failed to copy ConEmu.xml file to user-conemu.xml backup location!", MB_TITLE, MB_ICONSTOP);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -196,7 +193,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
{
|
{
|
||||||
MessageBox(NULL,
|
MessageBox(NULL,
|
||||||
(GetLastError() == ERROR_ACCESS_DENIED)
|
(GetLastError() == ERROR_ACCESS_DENIED)
|
||||||
? L"Failed to copy Cmder default ConEmu.xml file to vendored ConEmu.xml location! Restart Cmder as administrator."
|
? L"Failed to copy Cmder default ConEmu.xml file to vendored ConEmu.xml location! Restart Cmder as Administrator."
|
||||||
: L"Failed to copy Cmder default ConEmu.xml file to vendored ConEmu.xml location!", MB_TITLE, MB_ICONSTOP);
|
: L"Failed to copy Cmder default ConEmu.xml file to vendored ConEmu.xml location!", MB_TITLE, MB_ICONSTOP);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -237,7 +234,6 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
||||||
if (wcscmp(userConfigDirPath, configDirPath) != 0)
|
if (wcscmp(userConfigDirPath, configDirPath) != 0)
|
||||||
{
|
{
|
||||||
@ -310,33 +306,33 @@ void RegisterShellMenu(std::wstring opt, wchar_t* keyBaseName)
|
|||||||
|
|
||||||
GetModuleFileName(NULL, exePath, sizeof(exePath));
|
GetModuleFileName(NULL, exePath, sizeof(exePath));
|
||||||
|
|
||||||
wchar_t commandStr[MAX_PATH + 20] = { 0 };
|
wchar_t commandStr[MAX_PATH + 20] = { 0 };
|
||||||
swprintf_s(commandStr, L"\"%s\" \"%%V\"", exePath);
|
swprintf_s(commandStr, L"\"%s\" \"%%V\"", exePath);
|
||||||
|
|
||||||
// Now that we have `commandStr`, it's OK to change `exePath`...
|
// Now that we have `commandStr`, it's OK to change `exePath`...
|
||||||
PathRemoveFileSpec(exePath);
|
PathRemoveFileSpec(exePath);
|
||||||
|
|
||||||
PathCombine(icoPath, exePath, L"icons\\cmder.ico");
|
PathCombine(icoPath, exePath, L"icons\\cmder.ico");
|
||||||
|
|
||||||
// Now set the registry keys
|
// Now set the registry keys
|
||||||
HKEY root = GetRootKey(opt);
|
HKEY root = GetRootKey(opt);
|
||||||
|
|
||||||
HKEY cmderKey;
|
HKEY cmderKey;
|
||||||
FAIL_ON_ERROR(RegCreateKeyEx(root, keyBaseName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &cmderKey, NULL));
|
FAIL_ON_ERROR(RegCreateKeyEx(root, keyBaseName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &cmderKey, NULL));
|
||||||
|
|
||||||
FAIL_ON_ERROR(RegSetValue(cmderKey, L"", REG_SZ, L"Cmder Here", NULL));
|
FAIL_ON_ERROR(RegSetValue(cmderKey, L"", REG_SZ, L"Cmder Here", NULL));
|
||||||
FAIL_ON_ERROR(RegSetValueEx(cmderKey, L"NoWorkingDirectory", 0, REG_SZ, (BYTE *)L"", 2));
|
FAIL_ON_ERROR(RegSetValueEx(cmderKey, L"NoWorkingDirectory", 0, REG_SZ, (BYTE *)L"", 2));
|
||||||
|
|
||||||
FAIL_ON_ERROR(RegSetValueEx(cmderKey, L"Icon", 0, REG_SZ, (BYTE *)icoPath, wcslen(icoPath) * sizeof(wchar_t)));
|
FAIL_ON_ERROR(RegSetValueEx(cmderKey, L"Icon", 0, REG_SZ, (BYTE *)icoPath, wcslen(icoPath) * sizeof(wchar_t)));
|
||||||
|
|
||||||
HKEY command;
|
HKEY command;
|
||||||
FAIL_ON_ERROR(RegCreateKeyEx(cmderKey, L"command", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &command, NULL));
|
FAIL_ON_ERROR(RegCreateKeyEx(cmderKey, L"command", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &command, NULL));
|
||||||
|
|
||||||
FAIL_ON_ERROR(RegSetValue(command, L"", REG_SZ, commandStr, NULL));
|
FAIL_ON_ERROR(RegSetValue(command, L"", REG_SZ, commandStr, NULL));
|
||||||
|
|
||||||
RegCloseKey(command);
|
RegCloseKey(command);
|
||||||
RegCloseKey(cmderKey);
|
RegCloseKey(cmderKey);
|
||||||
RegCloseKey(root);
|
RegCloseKey(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnregisterShellMenu(std::wstring opt, wchar_t* keyBaseName)
|
void UnregisterShellMenu(std::wstring opt, wchar_t* keyBaseName)
|
||||||
@ -344,11 +340,7 @@ void UnregisterShellMenu(std::wstring opt, wchar_t* keyBaseName)
|
|||||||
HKEY root = GetRootKey(opt);
|
HKEY root = GetRootKey(opt);
|
||||||
HKEY cmderKey;
|
HKEY cmderKey;
|
||||||
FAIL_ON_ERROR(RegCreateKeyEx(root, keyBaseName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &cmderKey, NULL));
|
FAIL_ON_ERROR(RegCreateKeyEx(root, keyBaseName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &cmderKey, NULL));
|
||||||
#if XP
|
|
||||||
FAIL_ON_ERROR(SHDeleteKey(cmderKey, NULL));
|
|
||||||
#else
|
|
||||||
FAIL_ON_ERROR(RegDeleteTree(cmderKey, NULL));
|
FAIL_ON_ERROR(RegDeleteTree(cmderKey, NULL));
|
||||||
#endif
|
|
||||||
RegCloseKey(cmderKey);
|
RegCloseKey(cmderKey);
|
||||||
RegCloseKey(root);
|
RegCloseKey(root);
|
||||||
}
|
}
|
||||||
@ -363,7 +355,6 @@ struct cmderOptions
|
|||||||
bool registerApp = false;
|
bool registerApp = false;
|
||||||
bool unRegisterApp = false;
|
bool unRegisterApp = false;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
cmderOptions GetOption()
|
cmderOptions GetOption()
|
||||||
@ -464,11 +455,11 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||||||
|
|
||||||
cmderOptions cmderOptions = GetOption();
|
cmderOptions cmderOptions = GetOption();
|
||||||
|
|
||||||
if (cmderOptions.registerApp == true ) {
|
if (cmderOptions.registerApp == true) {
|
||||||
RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND);
|
RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND);
|
||||||
RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM);
|
RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM);
|
||||||
}
|
}
|
||||||
else if (cmderOptions.unRegisterApp == true )
|
else if (cmderOptions.unRegisterApp == true)
|
||||||
{
|
{
|
||||||
UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND);
|
UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND);
|
||||||
UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM);
|
UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM);
|
||||||
|
Loading…
Reference in New Issue
Block a user