• R/O
  • HTTP
  • SSH
  • HTTPS

xkeymacs: Commit


Commit MetaInfo

Revisionae9ad576b37bb3dc4b283cbe6bf172c263d3b6ef (tree)
Time2018-04-27 20:51:52
AuthorYujiSoftware <yuji.software+github@gmai...>
CommiterKazuhiro Fujieda @kfujieda

Log Message

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.

Change Summary

Incremental Difference

--- a/xkeymacs/profile.cpp
+++ b/xkeymacs/profile.cpp
@@ -528,8 +528,8 @@ void CProfile::ImportProperties()
528528 CFileDialog oFileOpenDialog(TRUE, _T("reg"), _T("xkeymacs"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, CString(MAKEINTRESOURCE(IDS_REGISTRATION_FILTER)));
529529 if (oFileOpenDialog.DoModal() == IDOK) {
530530 CString szCommandLine;
531- szCommandLine.Format(_T("regedit \"%s\""), oFileOpenDialog.GetPathName());
532- CUtils::Run(szCommandLine, TRUE); // regedit "x:\xkeymacs.reg"
531+ szCommandLine.Format(_T("reg import \"%s\""), oFileOpenDialog.GetPathName());
532+ CUtils::Run(szCommandLine, TRUE, TRUE); // reg import "x:\xkeymacs.reg"
533533 }
534534
535535 DiableTokenPrivileges();
@@ -545,8 +545,8 @@ void CProfile::ExportProperties()
545545 CFileDialog oFileOpenDialog(FALSE, _T("reg"), _T("xkeymacs"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, CString(MAKEINTRESOURCE(IDS_REGISTRATION_FILTER)));
546546 if (oFileOpenDialog.DoModal() == IDOK) {
547547 CString szCommandLine;
548- szCommandLine.Format(_T("regedit /e \"%s\" HKEY_CURRENT_USER\\%s"), oFileOpenDialog.GetPathName(), CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)));
549- CUtils::Run(szCommandLine, TRUE); // regedit /e "x:\xkeymacs.reg" HKEY_CURRENT_USER\Software\Oishi\XKeymacs2
548+ szCommandLine.Format(_T("reg export HKEY_CURRENT_USER\\%s \"%s\" /y"), CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)), oFileOpenDialog.GetPathName());
549+ CUtils::Run(szCommandLine, TRUE, TRUE); // reg export HKEY_CURRENT_USER\Software\Oishi\XKeymacs2 "x:\xkeymacs.reg" /y
550550 }
551551
552552 DiableTokenPrivileges();
--- a/xkeymacsdll/Utils.cpp
+++ b/xkeymacsdll/Utils.cpp
@@ -676,11 +676,15 @@ BOOL CUtils::IsBorlandCppBuilder()
676676 return AppName::Match(_T("bcb.exe"));
677677 }
678678
679-BOOL CUtils::Run(CString szCommandLine, BOOL isWait)
679+BOOL CUtils::Run(CString szCommandLine, BOOL isWait, BOOL isHide)
680680 {
681681 STARTUPINFO si;
682682 ZeroMemory(&si, sizeof(si));
683683 si.cb = sizeof(si);
684+ if (isHide) {
685+ si.dwFlags = STARTF_USESHOWWINDOW;
686+ si.wShowWindow = SW_HIDE;
687+ }
684688
685689 PROCESS_INFORMATION pi;
686690 ZeroMemory(&pi, sizeof(pi));
--- a/xkeymacsdll/Utils.h
+++ b/xkeymacsdll/Utils.h
@@ -25,7 +25,7 @@ public:
2525 static BOOL IsVisualSlickEdit();
2626 static BOOL IsMSDN();
2727 static BOOL IsJavaW();
28- static BOOL Run(CString szCommandLine, BOOL isWait = FALSE);
28+ static BOOL Run(CString szCommandLine, BOOL isWait = FALSE, BOOL isHide = FALSE);
2929 static BOOL IsBorlandCppBuilder();
3030 static BOOL IsLispWorksPersonalEdition();
3131 static BOOL IsTeraPad();
Show on old repository browser