[SHELL32] Minimal SHRunControlPanel implementation (#3095)
authorKyle Katarn <contact@kcsoftwares.com>
Sat, 19 Sep 2020 14:23:44 +0000 (16:23 +0200)
committerGitHub <noreply@github.com>
Sat, 19 Sep 2020 14:23:44 +0000 (16:23 +0200)
CORE-9215
Co-authored-by: Stanislav Motylkov <x86corez@gmail.com>
dll/win32/shell32/wine/shellord.c
sdk/include/psdk/shlobj.h

index ab0969a..37ff171 100644 (file)
@@ -1472,10 +1472,29 @@ HRESULT WINAPI SHWinHelp(HWND hwnd, LPCWSTR pszHelp, UINT uCommand, ULONG_PTR dw
  *  SHRunControlPanel [SHELL32.161]
  *
  */
-BOOL WINAPI SHRunControlPanel (LPCWSTR commandLine, HWND parent)
+BOOL WINAPI SHRunControlPanel (_In_ LPCWSTR commandLine, _In_opt_ HWND parent)
 {
+#ifdef __REACTOS__
+    /*
+     * TODO: Run in-process when possible, using
+     * HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\InProcCPLs
+     * and possibly some extra rules.
+     * See also https://docs.microsoft.com/en-us/windows/win32/api/shlobj/nf-shlobj-shruncontrolpanel
+     * "If the specified Control Panel item is already running, SHRunControlPanel
+     *  attempts to switch to that instance rather than opening a new instance."
+     * This function is not supported as of Windows Vista, where it always returns FALSE.
+     * However we need to keep it "alive" even when ReactOS is compliled as NT6+
+     * in order to keep control panel elements launch commands.
+     */
+    TRACE("(%s, %p)n", debugstr_w(commandLine), parent);
+    WCHAR parameters[MAX_PATH] = L"shell32.dll,Control_RunDLL ";
+    wcscat(parameters, commandLine);
+
+    return ((INT_PTR)ShellExecuteW(parent, L"open", L"rundll32.exe", parameters, NULL, SW_SHOWNORMAL) > 32);
+#else
        FIXME("(%s, %p): stub\n", debugstr_w(commandLine), parent);
        return FALSE;
+#endif
 }
 
 static LPUNKNOWN SHELL32_IExplorerInterface=0;
index b478ca2..422714c 100644 (file)
@@ -2466,6 +2466,16 @@ HRESULT WINAPI CIDLData_CreateFromIDArray(
   _In_reads_opt_(cidl) PCUIDLIST_RELATIVE_ARRAY apidl,
   _Outptr_ IDataObject **ppdtobj);
 
+/****************************************************************************
+ * SHRunControlPanel
+ */
+
+BOOL
+WINAPI
+SHRunControlPanel(
+  _In_ LPCWSTR commandLine,
+  _In_opt_ HWND parent);
+
 /****************************************************************************
  * SHOpenWithDialog
  */