[PATCH v3 0/1] MR9997: shell32: ShellExecute uses SW_SHOWDEFAULT by default
This patch applies to applications that launch processes via ShellDispatch without specifying a display mode (such as WPS PDF Editor). When no show parameter is specified, VT_EMPTY is converted to the integer 0 (i.e., SW_HIDE), causing the main window to be hidden by default. This behavior is now adjusted to use the default show mode. The modification references Microsoft’s official description of the IShellDispatch2.ShellExecute interface: "If this parameter is not specified, the application uses its default value." -- v3: 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
This merge request was closed by Fan Zhou. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9997
I don't know why this was closed, but optional arguments are expressed as VT_ERROR(DISP_E_PARAMNOTFOUND), see is_optional_argument() in the same file. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9997#note_128361
I don't know why this was closed, but optional arguments are expressed as VT_ERROR(DISP_E_PARAMNOTFOUND), see is_optional_argument() in the same file. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9997#note_128362
On Thu Jan 29 11:08:15 2026 +0000, Nikolay Sivov wrote:
I don't know why this was closed, but optional arguments are expressed as VT_ERROR(DISP_E_PARAMNOTFOUND), see is_optional_argument() in the same file. Thank you for your reply.
1. I closed this MR because I adjusted the formatting and submitted a new MR (with identical content) at:\ https://gitlab.winehq.org/wine/wine/-/merge_requests/9998 2. I am handling the VT_EMPTY type here because the program I migrated (WPS PDF Editor) passed this type as v_show, which resulted in the same behavior as when I set this parameter to 'EMPTY' via a VB script: the main window of the program failed to display. However, on the Windows platform, programs that provide this parameter can display the window normally. 3. Previously, I did not notice the logic of `is_optional_argument`. Should this function treat VT_EMPTY as a case where an optional argument is not specified, in order to maintain consistent behavior with the Windows platform? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9997#note_128364
I closed this MR because I adjusted the formatting and submitted a new MR (with identical content) at:
You don't need to do that, just do git push --force to the same branch, and it will update existing MR. This is better, because it preserves comments in one place.
I am handling the VT_EMPTY type here because the program I migrated (WPS PDF Editor) passed this type as v_show, which resulted in the same behavior as when I set this parameter to 'EMPTY' via a VB script: the main window of the program failed to display. However, on the Windows platform, programs that provide this parameter can display the window normally.
This is different from omitted optional argument, if you pass special Empty value in the script, it will be represented as VT_EMPTY, regardless of argument being optional.
Previously, I did not notice the logic of `is_optional_argument`. Should this function treat VT_EMPTY as a case where an optional argument is not specified, in order to maintain consistent behavior with the Windows platform?
I don't think so. For now it's fine to do that per-method. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9997#note_128366
On Thu Jan 29 11:17:35 2026 +0000, Nikolay Sivov wrote:
I closed this MR because I adjusted the formatting and submitted a new MR (with identical content) at: You don't need to do that, just do git push --force to the same branch, and it will update existing MR. This is better, because it preserves comments in one place. I am handling the VT_EMPTY type here because the program I migrated (WPS PDF Editor) passed this type as v_show, which resulted in the same behavior as when I set this parameter to 'EMPTY' via a VB script: the main window of the program failed to display. However, on the Windows platform, programs that provide this parameter can display the window normally. This is different from omitted optional argument, if you pass special Empty value in the script, it will be represented as VT_EMPTY, regardless of argument being optional. Previously, I did not notice the logic of `is_optional_argument`. Should this function treat VT_EMPTY as a case where an optional argument is not specified, in order to maintain consistent behavior with the Windows platform? I don't think so. For now it's fine to do that per-method. Thank you for pointing out these issues. Should I now update the commit message and description to reflect the compatibility handling for the VT_EMPTY parameter and proceed to merge it, or should I leave the function as it is?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9997#note_128367
participants (3)
-
Fan Zhou (@zhoufan_uniontech) -
Nikolay Sivov (@nsivov) -
zhoufan