https://git.reactos.org/?p=reactos.git;a=commitdiff;h=85a854f6b5bc98d652b438362c644efed240e120

commit 85a854f6b5bc98d652b438362c644efed240e120
Author:     Eric Kohl <[email protected]>
AuthorDate: Sun Feb 9 14:19:13 2020 +0100
Commit:     Eric Kohl <[email protected]>
CommitDate: Sun Feb 9 14:19:13 2020 +0100

    [MSPORTS] Notify the installer of changes to the configuration of serial or 
parallel ports
---
 dll/win32/msports/parallel.c | 48 ++++++++++++++++++++++++++++++++++----------
 dll/win32/msports/serial.c   | 16 +++++++++++++++
 2 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/dll/win32/msports/parallel.c b/dll/win32/msports/parallel.c
index b06fd9eef6e..abf2d7fa6ee 100644
--- a/dll/win32/msports/parallel.c
+++ b/dll/win32/msports/parallel.c
@@ -248,12 +248,14 @@ WritePortSettings(
     HWND hwnd,
     PPORT_DATA pPortData)
 {
+    SP_PROPCHANGE_PARAMS PropChangeParams;
     DWORD dwDisposition;
     DWORD dwFilterResourceMethod;
     DWORD dwLegacy;
     DWORD dwPortNumber;
     DWORD dwPortMap;
     HKEY hKey;
+    BOOL bChanged = FALSE;
     DWORD dwError;
 
     TRACE("WritePortSettings(%p)\n", pPortData);
@@ -282,13 +284,12 @@ WritePortSettings(
                                      REG_DWORD,
                                      (PBYTE)&dwFilterResourceMethod,
                                      sizeof(dwFilterResourceMethod));
-            if (dwError != ERROR_SUCCESS)
+            RegCloseKey(hKey);
+            if (dwError == ERROR_SUCCESS)
             {
-                ERR("RegSetValueExW failed (Error %lu)\n", dwError);
+                pPortData->dwFilterResourceMethod = dwFilterResourceMethod;
+                bChanged = TRUE;
             }
-
-            RegCloseKey(hKey);
-            pPortData->dwFilterResourceMethod = dwFilterResourceMethod;
         }
     }
 
@@ -319,9 +320,8 @@ WritePortSettings(
 
             if (dwError == ERROR_SUCCESS)
             {
-                FIXME("Notify the driver!\n");
-
                 pPortData->dwLegacy = dwLegacy;
+                bChanged = TRUE;
             }
         }
     }
@@ -337,13 +337,39 @@ WritePortSettings(
             if (dwPortMap & 1 << dwPortNumber)
             {
                 ERR("Port LPT%lu is already in use!\n", dwPortNumber);
-                return;
             }
-
-            ChangePortNumber(pPortData,
-                             dwPortNumber);
+            else
+            {
+                ChangePortNumber(pPortData,
+                                 dwPortNumber);
+                bChanged = TRUE;
+            }
         }
     }
+
+    if (bChanged)
+    {
+        /* Notify the system */
+        PostMessageW(HWND_BROADCAST,
+                     WM_WININICHANGE,
+                     0,
+                     (LPARAM)pPortData->szPortName);
+
+        /* Notify the installer (and device) */
+        PropChangeParams.ClassInstallHeader.cbSize = 
sizeof(SP_CLASSINSTALL_HEADER);
+        PropChangeParams.ClassInstallHeader.InstallFunction = 
DIF_PROPERTYCHANGE;
+        PropChangeParams.Scope = DICS_FLAG_GLOBAL;
+        PropChangeParams.StateChange = DICS_PROPCHANGE;
+
+        SetupDiSetClassInstallParams(pPortData->DeviceInfoSet,
+                                     pPortData->DeviceInfoData,
+                                     
(PSP_CLASSINSTALL_HEADER)&PropChangeParams,
+                                     sizeof(SP_PROPCHANGE_PARAMS));
+
+        SetupDiCallClassInstaller(DIF_PROPERTYCHANGE,
+                                  pPortData->DeviceInfoSet,
+                                  pPortData->DeviceInfoData);
+    }
 }
 
 
diff --git a/dll/win32/msports/serial.c b/dll/win32/msports/serial.c
index 768fedf6046..515e7eace33 100644
--- a/dll/win32/msports/serial.c
+++ b/dll/win32/msports/serial.c
@@ -229,6 +229,7 @@ WritePortSettings(
     HWND hwnd,
     PPORT_DATA pPortData)
 {
+    SP_PROPCHANGE_PARAMS PropChangeParams;
     WCHAR szPortData[32];
     HWND hwndControl;
     INT nBaudRateIndex;
@@ -329,6 +330,21 @@ WritePortSettings(
                  0,
                  (LPARAM)pPortData->szPortName);
 
+    /* Notify the installer (and device) */
+    PropChangeParams.ClassInstallHeader.cbSize = 
sizeof(SP_CLASSINSTALL_HEADER);
+    PropChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
+    PropChangeParams.Scope = DICS_FLAG_GLOBAL;
+    PropChangeParams.StateChange = DICS_PROPCHANGE;
+
+    SetupDiSetClassInstallParams(pPortData->DeviceInfoSet,
+                                 pPortData->DeviceInfoData,
+                                 (PSP_CLASSINSTALL_HEADER)&PropChangeParams,
+                                 sizeof(SP_PROPCHANGE_PARAMS));
+
+    SetupDiCallClassInstaller(DIF_PROPERTYCHANGE,
+                              pPortData->DeviceInfoSet,
+                              pPortData->DeviceInfoData);
+
     TRACE("Done!\n");
 }
 

Reply via email to