From a83411cfefeb5dc523e7432756aef153016e9c00 Mon Sep 17 00:00:00 2001 From: Whindmar Saksit Date: Sun, 14 Jun 2026 00:24:59 +0200 Subject: [PATCH] [SHELL32] Avoid SHRunControlPanel to be Vista compatible (#9114) --- base/shell/explorer/trayclock.cpp | 1 - base/shell/explorer/traywnd.cpp | 2 -- dll/win32/shell32/CShellDispatch.cpp | 8 +++++++- dll/win32/shell32/precomp.h | 5 ++++- dll/win32/shell32/wine/shellord.c | 21 +++++++++++++++++---- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/base/shell/explorer/trayclock.cpp b/base/shell/explorer/trayclock.cpp index 48ec1d4d543..04c131e7bc0 100644 --- a/base/shell/explorer/trayclock.cpp +++ b/base/shell/explorer/trayclock.cpp @@ -754,7 +754,6 @@ LRESULT CTrayClockWnd::OnLButtonDblClick(UINT uMsg, WPARAM wParam, LPARAM lParam { if (IsWindowVisible()) { - //FIXME: use SHRunControlPanel ShellExecuteW(m_hWnd, NULL, L"timedate.cpl", NULL, NULL, SW_NORMAL); } return TRUE; diff --git a/base/shell/explorer/traywnd.cpp b/base/shell/explorer/traywnd.cpp index 38bdca498dd..409abaede7f 100644 --- a/base/shell/explorer/traywnd.cpp +++ b/base/shell/explorer/traywnd.cpp @@ -723,7 +723,6 @@ public: break; case ID_SHELL_CMD_ADJUST_DAT: - //FIXME: Use SHRunControlPanel ShellExecuteW(m_hWnd, NULL, L"timedate.cpl", NULL, NULL, SW_NORMAL); break; @@ -779,7 +778,6 @@ public: SHFindComputer(NULL, NULL); break; case IDHK_SYS_PROPERTIES: - //FIXME: Use SHRunControlPanel ShellExecuteW(m_hWnd, NULL, L"sysdm.cpl", NULL, NULL, SW_NORMAL); break; case IDHK_NEXT_TASK: diff --git a/dll/win32/shell32/CShellDispatch.cpp b/dll/win32/shell32/CShellDispatch.cpp index 386cf9bf2b5..d8e354fe1f2 100644 --- a/dll/win32/shell32/CShellDispatch.cpp +++ b/dll/win32/shell32/CShellDispatch.cpp @@ -267,7 +267,13 @@ HRESULT STDMETHODCALLTYPE CShellDispatch::RefreshMenu() HRESULT STDMETHODCALLTYPE CShellDispatch::ControlPanelItem(BSTR szDir) { TRACE("(%p, %ls)\n", this, szDir); - return SHRunControlPanel(szDir, NULL) ? S_OK : S_FALSE; + if (LOBYTE(GetVersion()) < 6) + SHELL32_RunControlPanel(szDir, NULL); + else if (!szDir) + return E_INVALIDARG; // NT5 does not check, just silently fails + else + ShellExecuteW(NULL, NULL, szDir, NULL, NULL, SW_SHOWNORMAL); + return S_OK; } // *** IShellDispatch2 methods *** diff --git a/dll/win32/shell32/precomp.h b/dll/win32/shell32/precomp.h index 4cacbaf8579..e9620f76415 100644 --- a/dll/win32/shell32/precomp.h +++ b/dll/win32/shell32/precomp.h @@ -213,7 +213,10 @@ UINT MapVerbToDfmCmd(_In_ LPCSTR verba); UINT GetDfmCmd(_In_ IContextMenu *pCM, _In_ LPCSTR verba); -#define SHELL_ExecuteControlPanelCPL(hwnd, cpl) SHRunControlPanel((cpl), (hwnd)) + +EXTERN_C BOOL WINAPI +SHELL32_RunControlPanel(_In_ PCWSTR commandLine, _In_opt_ HWND parent); +#define SHELL_ExecuteControlPanelCPL(hwnd, cpl) SHELL32_RunControlPanel((cpl), (hwnd)) // CStubWindow32 --- The owner window of file property sheets. diff --git a/dll/win32/shell32/wine/shellord.c b/dll/win32/shell32/wine/shellord.c index fca6e7a2d64..e1b5f00c9e4 100644 --- a/dll/win32/shell32/wine/shellord.c +++ b/dll/win32/shell32/wine/shellord.c @@ -1663,9 +1663,10 @@ HRESULT WINAPI SHWinHelp(HWND hwnd, LPCWSTR pszHelp, UINT uCommand, ULONG_PTR dw * SHRunControlPanel [SHELL32.161] * */ -BOOL WINAPI SHRunControlPanel (_In_ LPCWSTR commandLine, _In_opt_ HWND parent) -{ #ifdef __REACTOS__ +EXTERN_C BOOL WINAPI +SHELL32_RunControlPanel(_In_ PCWSTR commandLine, _In_opt_ HWND parent) +{ /* * TODO: Run in-process when possible, using * HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\InProcCPLs @@ -1678,10 +1679,22 @@ BOOL WINAPI SHRunControlPanel (_In_ LPCWSTR commandLine, _In_opt_ HWND parent) * in order to keep control panel elements launch commands. */ WCHAR parameters[MAX_PATH] = L"shell32.dll,Control_RunDLL "; - TRACE("(%s, %p)n", debugstr_w(commandLine), parent); + if (!commandLine) + return FALSE; wcscat(parameters, commandLine); - return ((INT_PTR)ShellExecuteW(parent, L"open", L"rundll32.exe", parameters, NULL, SW_SHOWNORMAL) > 32); +} +#endif + +BOOL WINAPI SHRunControlPanel(_In_ LPCWSTR commandLine, _In_opt_ HWND parent) +{ +#ifdef __REACTOS__ + TRACE("(%s, %p)n", debugstr_w(commandLine), parent); + /* MSDN indicates that ROS should have a version check here but Vista+ just forwards to SHUNIMPL + if (LOBYTE(GetVersion()) >= 6) + return FALSE; + */ + return SHELL32_RunControlPanel(commandLine, parent); #else FIXME("(%s, %p): stub\n", debugstr_w(commandLine), parent); return FALSE;