[FarGroup/FarManager] master: Set SHELLEXECUTEINFO.hwnd properly (f7745c5d7)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Jan 4, 2026, 11:45:56 AM (12 days ago) Jan 4
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/f7745c5d759739cd204a9d6ac5a201ffd1f16325

>---------------------------------------------------------------

commit f7745c5d759739cd204a9d6ac5a201ffd1f16325
Author: Alex Alabuzhev <alab...@gmail.com>
Date: Sun Jan 4 16:31:13 2026 +0000

Set SHELLEXECUTEINFO.hwnd properly

According to rumors, it should help in certain corner cases


>---------------------------------------------------------------

f7745c5d759739cd204a9d6ac5a201ffd1f16325
far/changelog | 6 ++++++
far/elevation.cpp | 15 ++++++++-------
far/execute.cpp | 18 +++++++++++-------
far/setattr.cpp | 19 ++++++++++++-------
far/vbuild.m4 | 2 +-
5 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/far/changelog b/far/changelog
index 9beb80211..872fc9e01 100644
--- a/far/changelog
+++ b/far/changelog
@@ -1,3 +1,9 @@
+--------------------------------------------------------------------------------
+drkns 2026-01-04 16:30:34+00:00 - build 6624
+
+1. Set SHELLEXECUTEINFO.hwnd properly.
+ According to rumors, it should help in certain corner cases.
+
--------------------------------------------------------------------------------
drkns 2026-01-03 19:05:39+00:00 - build 6623

diff --git a/far/elevation.cpp b/far/elevation.cpp
index 068a159b2..ffd48dbd6 100644
--- a/far/elevation.cpp
+++ b/far/elevation.cpp
@@ -422,13 +422,14 @@ static os::handle create_elevated_process(const string& Parameters)
{
SHELLEXECUTEINFO info
{
- sizeof(info),
- SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS,
- nullptr,
- L"runas",
- Global->g_strFarModuleName.c_str(),
- Parameters.c_str(),
- Global->g_strFarPath.c_str(),
+ .cbSize = sizeof(info),
+ .fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS,
+ .hwnd = console.GetWindow(),
+ .lpVerb = L"runas",
+ .lpFile = Global->g_strFarModuleName.c_str(),
+ .lpParameters = Parameters.c_str(),
+ .lpDirectory = Global->g_strFarPath.c_str(),
+ .nShow = SW_HIDE,
};

if (!ShellExecuteEx(&info))
diff --git a/far/execute.cpp b/far/execute.cpp
index 5e50c1f5a..00ab22ad4 100644
--- a/far/execute.cpp
+++ b/far/execute.cpp
@@ -643,13 +643,17 @@ static bool execute_createprocess(string const& Command, string const& Parameter

static bool execute_shell(string const& Command, string const& Parameters, string const& Directory, execute_info::source_mode const SourceMode, bool const RunAs, bool const Wait, HANDLE& Process)
{
- SHELLEXECUTEINFO Info{ sizeof(Info) };
- Info.lpFile = Command.c_str();
- Info.lpParameters = EmptyToNull(Parameters);
- Info.lpDirectory = Directory.c_str();
- Info.nShow = SW_SHOWNORMAL;
- Info.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS | (Wait? SEE_MASK_NO_CONSOLE : 0);
- Info.lpVerb = RunAs? L"runas" : nullptr;
+ SHELLEXECUTEINFO Info
+ {
+ .cbSize = sizeof(Info),
+ .fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS | (Wait? SEE_MASK_NO_CONSOLE : 0ul),
+ .hwnd = console.GetWindow(),
+ .lpVerb = RunAs? L"runas" : nullptr,
+ .lpFile = Command.c_str(),
+ .lpParameters = EmptyToNull(Parameters),
+ .lpDirectory = Directory.c_str(),
+ .nShow = SW_SHOWNORMAL,
+ };

if (any_of(SourceMode, execute_info::source_mode::known, execute_info::source_mode::known_executable))
{
diff --git a/far/setattr.cpp b/far/setattr.cpp
index ecff55279..88012955c 100644
--- a/far/setattr.cpp
+++ b/far/setattr.cpp
@@ -1469,10 +1469,6 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)
if (!os::is_interactive_user_session())
return true;

- SHELLEXECUTEINFO seInfo{ sizeof(seInfo) };
- seInfo.nShow = SW_SHOW;
- seInfo.fMask = SEE_MASK_INVOKEIDLIST;
-
string strFullName;

if (DriveLetter)
@@ -1489,10 +1485,19 @@ static bool ShellSetFileAttributesImpl(Panel* SrcPanel, const string* Object)
AddEndSlash(strFullName);
}

- seInfo.lpFile = strFullName.c_str();
- seInfo.lpVerb = L"properties";
const auto strCurDir = os::fs::get_current_directory();
- seInfo.lpDirectory=strCurDir.c_str();
+
+ SHELLEXECUTEINFO seInfo
+ {
+ .cbSize = sizeof(seInfo),
+ .fMask = SEE_MASK_INVOKEIDLIST,
+ .hwnd = console.GetWindow(),
+ .lpVerb = L"properties",
+ .lpFile = strFullName.c_str(),
+ .lpDirectory = strCurDir.c_str(),
+ .nShow = SW_SHOWNORMAL,
+ };
+
ShellExecuteEx(&seInfo);
}
return false;
diff --git a/far/vbuild.m4 b/far/vbuild.m4
index 0dd0a715d..aa594df5f 100644
--- a/far/vbuild.m4
+++ b/far/vbuild.m4
@@ -1 +1 @@
-6623
+6624


Reply all
Reply to author
Forward
0 new messages