同步操作将从 精易科技/eapi 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "..\include_eapi_header.h"#include <optional>#include <algorithm>using namespace std;#undef maxnamespace eapiRightMenu{static std::string ReplaceSubText(std::string text, const std::string& to_replace, std::optional<size_t> replace_count = std::nullopt) {size_t search_start = 0;size_t count = replace_count.value_or(std::numeric_limits<size_t>::max());std::string replace = "";size_t pos = text.find(to_replace, search_start);while (pos != std::string::npos && count > 0) {text.replace(pos, to_replace.length(), replace);pos = text.find(to_replace, pos + replace.length());--count;}return text;}static vector<string> EnumRegistryKey(HKEY root, string path){REGSAM Type;HKEY pHkey;SYSTEM_INFO INFO;std::vector<string> ret;pHkey = 0;GetNativeSystemInfo(&INFO);if (INFO.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || (Type = KEY_WOW64_32KEY | KEY_ALL_ACCESS, INFO.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)) {Type = KEY_WOW64_64KEY | KEY_ALL_ACCESS;}RegOpenKeyExA(root, path.c_str(), 1, Type, &pHkey);char name[MAX_PATH] = {};if (!RegEnumKeyA(pHkey, 0, name, MAX_PATH)){ret.push_back(name);if (!RegEnumKeyA(pHkey, 1, name, MAX_PATH)){DWORD i = 2;do {ret.push_back(name);} while (!RegEnumKeyA(pHkey, i++, name, MAX_PATH));}RegCloseKey(pHkey);}return ret;}static void DleteMore(const string& name, HKEY hkey, const string& parpath, HKEY handle, const string& livepath){vector<string> data;DWORD samDesired;SYSTEM_INFO SystemInfo;string needhandle;GetNativeSystemInfo(&SystemInfo);if (SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 || (samDesired = KEY_WOW64_32KEY, SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)) {samDesired = KEY_WOW64_64KEY;}do{data = EnumRegistryKey(hkey, livepath);for (size_t i = 0; i < data.size(); ++i){if (!EnumRegistryKey(hkey, livepath + "\\" + data[i]).empty()) {DleteMore(name, hkey, parpath, handle, livepath + "\\" + data[i]);}else {needhandle = ReplaceSubText(livepath + "\\" + data[i], parpath + "\\", 1);RegDeleteKeyExA(handle, needhandle.c_str(), samDesired, 0);}}} while (EnumRegistryKey(hkey, livepath).size() >= 1);needhandle = ReplaceSubText(livepath, parpath + "\\");RegDeleteKeyExA(handle, needhandle.c_str(), samDesired, 0);}/*** @brief 删除带有给定标题的右键菜单。** @param 要使用的范围或扩展名。* @param Title要删除的右键菜单的标题。** @return 如果成功删除右键菜单,返回 true,否则返回false。*/static bool DeleteRightMenu(const string& Rangeorextensiontobeused, const string& Title) {SYSTEM_INFO SystemInfo;GetNativeSystemInfo(&SystemInfo);REGSAM Accessrights, samDesired;if (SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || (Accessrights = KEY_WOW64_32KEY | KEY_ALL_ACCESS, SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)) {Accessrights = KEY_WOW64_64KEY | KEY_ALL_ACCESS;}if (SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || (samDesired = KEY_WOW64_32KEY, SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)){samDesired = KEY_WOW64_64KEY;}HKEY hKey;;if (RegOpenKeyExA(HKEY_CLASSES_ROOT, 0, 0, Accessrights, &hKey) != ERROR_SUCCESS){return false;}if (!EnumRegistryKey(HKEY_CLASSES_ROOT, "\\" + Title).empty()){DleteMore(Title, HKEY_CLASSES_ROOT, "", hKey, "\\" + Title);}else if (RegDeleteKeyExA(hKey, Title.c_str(), samDesired, 0)) {RegCloseKey(hKey);return false;};RegCloseKey(hKey);return true;}/*** @brief 用于在 Windows 系统中添加右键菜单** @param rangeOrExtensionToBeUsed:使用的范围或扩展名* @param title:要添加的右键菜单的标题。* @param comLine:右键菜单的命令行。* @param shortKey:右键菜单的快捷键。* @param icon:右键菜单的图标。* @param shiftDisplay:右键菜单的显示位置(是否在Shift按下时显示)。** @return 如果成功删除右键菜单,返回 true,否则返回false。*/static bool AddRightMenu(const std::string& Rangeorextensiontobeused,const std::string& Title,const std::string& comline,const std::string& shortkey,const std::string& icon,bool shiftdisplay) {string Actionpath;if (Rangeorextensiontobeused == "*"){Actionpath = "Directory\\Background\\shell";}else if (Rangeorextensiontobeused == "D"){Actionpath = "DesktopBackground\\Shell";}else if (Rangeorextensiontobeused == "URL"){Actionpath = "Directory\\shell";}else{Actionpath = "*\\shell";if (Rangeorextensiontobeused != "SAVER") {Actionpath = Rangeorextensiontobeused;}}HKEY phkResult = 0;SYSTEM_INFO SystemInfo;GetNativeSystemInfo(&SystemInfo);REGSAM Accessrights, samDesired;if (SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || (Accessrights = KEY_WOW64_32KEY | KEY_ALL_ACCESS, SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)) {Accessrights = KEY_WOW64_64KEY | KEY_ALL_ACCESS;}if (SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || (samDesired = KEY_WOW64_32KEY, SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)){samDesired = KEY_WOW64_64KEY;}RegCreateKeyExA(HKEY_CLASSES_ROOT, Actionpath.c_str(), 0, 0, 0, Accessrights, 0, &phkResult, 0);if (!phkResult) {return false;}RegSetValueExA(phkResult, "SubCommands", 0, REG_SZ, 0, 0);RegCloseKey(phkResult);string lpSubKey = Actionpath + "\\shell";GetNativeSystemInfo(&SystemInfo);RegCreateKeyExA(HKEY_CLASSES_ROOT, lpSubKey.c_str(), 0, 0, 0, Accessrights, 0, &phkResult, 0);if (!phkResult) {return false;}HKEY hKey = 0;RegOpenKeyExA(HKEY_CLASSES_ROOT, lpSubKey.c_str(), 0, Accessrights, &hKey);string lpPstr = lpSubKey;lpSubKey = lpSubKey + "\\" + Actionpath + "\\shell" + "\\" + Title;if (EnumRegistryKey(HKEY_CLASSES_ROOT, lpSubKey).size() <= 0) {RegDeleteKeyExA(hKey, (Actionpath + "\\shell" + "\\" + Title).c_str(), samDesired, 0);}else{DleteMore((Actionpath + "\\shell" + "\\" + Title), HKEY_CLASSES_ROOT, lpPstr, hKey, lpSubKey);}RegCloseKey(hKey);;RegCloseKey(phkResult);RegCreateKeyExA(HKEY_CLASSES_ROOT, (Actionpath + "\\shell" + "\\" + Title).c_str(), 0, 0, 0, Accessrights, 0, &phkResult, 0);if (!phkResult) {return false;}if (!shortkey.empty()){string temp = Title + "(&" + shortkey + ")";RegSetValueExA(phkResult, "MUIVerb", 0, REG_SZ, (const BYTE*)temp.c_str(), temp.size());}else{RegSetValueExA(phkResult, "MUIVerb", 0, REG_SZ, (const BYTE*)Title.c_str(), Title.size());}if (!icon.empty()){RegSetValueExA(phkResult, "icon", 0, REG_SZ, (const BYTE*)icon.c_str(), icon.size());}if (shiftdisplay) {RegSetValueExA(phkResult, "Extended", 0, REG_SZ, 0, 0);}RegCloseKey(phkResult);RegCreateKeyExA(HKEY_CLASSES_ROOT, (Actionpath + "\\shell" + "\\" + Title + "\\command").c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, Accessrights, NULL, &phkResult, NULL);if (phkResult){RegSetValueExA(phkResult, 0, 0, REG_SZ, (const BYTE*)comline.c_str(), comline.size());return 1;}return 0;}};EAPI_EXTERN_C void eapi_AddRightMenu_23_eapi(PMDATA_INF pRetData, INT nArgCount, PMDATA_INF pArgInf){std::string RangeOrExtName = "*", title, commandline, shortkey, icon;BOOL shiftdisplay = FALSE;if (pArgInf[0].m_dtDataType && pArgInf[0].m_pText && strlen(pArgInf[0].m_pText)){RangeOrExtName = pArgInf[0].m_pText;}if (pArgInf[1].m_dtDataType && pArgInf[1].m_pText){title = pArgInf[1].m_pText;}if (pArgInf[2].m_dtDataType && pArgInf[2].m_pText){commandline = pArgInf[2].m_pText;}if (pArgInf[3].m_dtDataType && pArgInf[3].m_pText){shortkey = pArgInf[3].m_pText;}if (pArgInf[4].m_dtDataType && pArgInf[4].m_pText){icon = pArgInf[4].m_pText;}if (pArgInf[5].m_dtDataType){shiftdisplay = pArgInf[5].m_bool;}pRetData->m_bool = eapiRightMenu::AddRightMenu(RangeOrExtName, title, commandline, shortkey, icon, shiftdisplay);}EAPI_EXTERN_C void eapi_DeleteRightMenu_24_eapi(PMDATA_INF pRetData, INT nArgCount, PMDATA_INF pArgInf){std::string RangeOrExtName = "*", title;BOOL shiftdisplay = FALSE;if (pArgInf[0].m_dtDataType && pArgInf[0].m_pText && strlen(pArgInf[0].m_pText)){RangeOrExtName = pArgInf[0].m_pText;}if (pArgInf[1].m_dtDataType && pArgInf[1].m_pText){title = pArgInf[1].m_pText;}pRetData->m_bool = eapiRightMenu::DeleteRightMenu(title, RangeOrExtName);}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。