From: YujiSoftware Date: Fri, 27 Apr 2018 11:51:52 +0000 (+0900) Subject: Use the reg command to import/export properties X-Git-Url: http://git.osdn.net/view?p=xkeymacs%2Fxkeymacs.git;a=commitdiff_plain;h=ae9ad576b37bb3dc4b283cbe6bf172c263d3b6ef Use the reg command to import/export properties Import/export properties fail because the regedit command can't run for lack of administrator privileges. Use the reg command instead. --- diff --git a/xkeymacs/profile.cpp b/xkeymacs/profile.cpp index f01749b..c584f57 100644 --- a/xkeymacs/profile.cpp +++ b/xkeymacs/profile.cpp @@ -528,8 +528,8 @@ void CProfile::ImportProperties() CFileDialog oFileOpenDialog(TRUE, _T("reg"), _T("xkeymacs"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, CString(MAKEINTRESOURCE(IDS_REGISTRATION_FILTER))); if (oFileOpenDialog.DoModal() == IDOK) { CString szCommandLine; - szCommandLine.Format(_T("regedit \"%s\""), oFileOpenDialog.GetPathName()); - CUtils::Run(szCommandLine, TRUE); // regedit "x:\xkeymacs.reg" + szCommandLine.Format(_T("reg import \"%s\""), oFileOpenDialog.GetPathName()); + CUtils::Run(szCommandLine, TRUE, TRUE); // reg import "x:\xkeymacs.reg" } DiableTokenPrivileges(); @@ -545,8 +545,8 @@ void CProfile::ExportProperties() CFileDialog oFileOpenDialog(FALSE, _T("reg"), _T("xkeymacs"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, CString(MAKEINTRESOURCE(IDS_REGISTRATION_FILTER))); if (oFileOpenDialog.DoModal() == IDOK) { CString szCommandLine; - szCommandLine.Format(_T("regedit /e \"%s\" HKEY_CURRENT_USER\\%s"), oFileOpenDialog.GetPathName(), CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA))); - CUtils::Run(szCommandLine, TRUE); // regedit /e "x:\xkeymacs.reg" HKEY_CURRENT_USER\Software\Oishi\XKeymacs2 + szCommandLine.Format(_T("reg export HKEY_CURRENT_USER\\%s \"%s\" /y"), CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)), oFileOpenDialog.GetPathName()); + CUtils::Run(szCommandLine, TRUE, TRUE); // reg export HKEY_CURRENT_USER\Software\Oishi\XKeymacs2 "x:\xkeymacs.reg" /y } DiableTokenPrivileges(); diff --git a/xkeymacsdll/Utils.cpp b/xkeymacsdll/Utils.cpp index 4636ec6..f21aeec 100644 --- a/xkeymacsdll/Utils.cpp +++ b/xkeymacsdll/Utils.cpp @@ -676,11 +676,15 @@ BOOL CUtils::IsBorlandCppBuilder() return AppName::Match(_T("bcb.exe")); } -BOOL CUtils::Run(CString szCommandLine, BOOL isWait) +BOOL CUtils::Run(CString szCommandLine, BOOL isWait, BOOL isHide) { STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); + if (isHide) { + si.dwFlags = STARTF_USESHOWWINDOW; + si.wShowWindow = SW_HIDE; + } PROCESS_INFORMATION pi; ZeroMemory(&pi, sizeof(pi)); diff --git a/xkeymacsdll/Utils.h b/xkeymacsdll/Utils.h index 3cee61b..2a30746 100644 --- a/xkeymacsdll/Utils.h +++ b/xkeymacsdll/Utils.h @@ -25,7 +25,7 @@ public: static BOOL IsVisualSlickEdit(); static BOOL IsMSDN(); static BOOL IsJavaW(); - static BOOL Run(CString szCommandLine, BOOL isWait = FALSE); + static BOOL Run(CString szCommandLine, BOOL isWait = FALSE, BOOL isHide = FALSE); static BOOL IsBorlandCppBuilder(); static BOOL IsLispWorksPersonalEdition(); static BOOL IsTeraPad();