[PATCH v5 0/2] MR9997: shell32: ShellExecute uses SW_SHOWDEFAULT by default
This patch applies to applications that launch processes via ShellDispatch specified as VT_EMPTY type (such as WPS PDF Editor).\ It prevents the conversion of VT_EMPTY type to the INT_4 value of 0 (i.e., SW_HIDE), which would otherwise cause the main program window not to be displayed. -- v5: shell32: ShellExecute uses SW_SHOWDEFAULT by default https://gitlab.winehq.org/wine/wine/-/merge_requests/9997
From: zhoufan <zhoufan@uniontech.com> --- dlls/shell32/shelldispatch.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dlls/shell32/shelldispatch.c b/dlls/shell32/shelldispatch.c index 06b853ca3dc..e1234c0c36b 100644 --- a/dlls/shell32/shelldispatch.c +++ b/dlls/shell32/shelldispatch.c @@ -2400,7 +2400,7 @@ static HRESULT WINAPI ShellDispatch_ShellExecute(IShellDispatch6 *iface, { VARIANT args_str, dir_str, op_str, show_int; WCHAR *args = NULL, *dir = NULL, *op = NULL; - INT show = 0; + INT show = 10; /* use default state specified by the application*/ HINSTANCE ret; TRACE("(%s, %s, %s, %s, %s)\n", debugstr_w(file), debugstr_variant(&v_args), @@ -2421,10 +2421,14 @@ static HRESULT WINAPI ShellDispatch_ShellExecute(IShellDispatch6 *iface, if (V_VT(&op_str) == VT_BSTR) op = V_BSTR(&op_str); - VariantInit(&show_int); - VariantChangeType(&show_int, &v_show, 0, VT_I4); - if (V_VT(&show_int) == VT_I4) - show = V_I4(&show_int); + /* check if show parameter is specified*/ + if(V_VT(&v_show) != VT_EMPTY) + { + VariantInit(&show_int); + VariantChangeType(&show_int, &v_show, 0, VT_I4); + if (V_VT(&show_int) == VT_I4) + show = V_I4(&show_int); + } ret = ShellExecuteW(NULL, op, file, args, dir, show); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9997
From: zhoufan <zhoufan@uniontech.com> --- dlls/shell32/shelldispatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/shell32/shelldispatch.c b/dlls/shell32/shelldispatch.c index e1234c0c36b..633ee4f2b7b 100644 --- a/dlls/shell32/shelldispatch.c +++ b/dlls/shell32/shelldispatch.c @@ -2400,7 +2400,7 @@ static HRESULT WINAPI ShellDispatch_ShellExecute(IShellDispatch6 *iface, { VARIANT args_str, dir_str, op_str, show_int; WCHAR *args = NULL, *dir = NULL, *op = NULL; - INT show = 10; /* use default state specified by the application*/ + INT show = SW_SHOWDEFAULT; /* use default state specified by the application*/ HINSTANCE ret; TRACE("(%s, %s, %s, %s, %s)\n", debugstr_w(file), debugstr_variant(&v_args), @@ -2421,7 +2421,7 @@ static HRESULT WINAPI ShellDispatch_ShellExecute(IShellDispatch6 *iface, if (V_VT(&op_str) == VT_BSTR) op = V_BSTR(&op_str); - /* check if show parameter is specified*/ + /* use default if VT_EMPTY is specified */ if(V_VT(&v_show) != VT_EMPTY) { VariantInit(&show_int); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9997
Commits need to be squashed. To better understand how this should be fixed, could you tell how this is called by the application? Is it called directly or from automation/scripting? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9997#note_130252
On Wed Mar 4 05:30:34 2026 +0000, Nikolay Sivov wrote:
Commits need to be squashed. To better understand how this should be fixed, could you tell how this is called by the application? Is it called directly or from automation/scripting? Through analysis of the call stack, the application delegates the process creation behavior to explorer.exe by invoking COM interfaces via RPC. The specific process is as follows:
(1) Create a IShellWindows instance of the local service(CLSCTX_LOCAL_SERVER).\ 0168:trace:ole:CoCreateInstanceEx {9ba05972-f6a8-11cf-a442-00a0c90a8f39}, 00000000, 0x4, 00000000, 1, 0012BB64 (2) Obtain the IDispatch object via the FindWindowSW interface.\ 004c:0050:trace:explorer:shellwindows_FindWindowSW iface 000000000041F240, location 00007FFFFE966460, root 00007FFFFE9665A0, class 0x8, hwnd 00007FFFFE94A150, options 0x1, disp 00007FFFFE94A180.\ 004c:0050:trace:shell:shellfolderviewdual_get_Application 00007FFFFE92AF90 00007FFFFE948210 (3) Invoke the ShellExecute interface.\ 004c:0050:trace:shell:ShellDispatch_ShellExecute (..., 00007FFFFE95F020 {VT_EMPTY}, 00007FFFFE95F060 {VT_EMPTY}, 00007FFFFE95F0A0 {VT_EMPTY}) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9997#note_131193
participants (3)
-
Fan Zhou (@zhoufan_uniontech) -
Nikolay Sivov (@nsivov) -
zhoufan