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

commit bcedb5314c0d0e83e62ca1602c19d5c993f69440
Author:     Eric Kohl <eric.k...@reactos.org>
AuthorDate: Sun Mar 16 14:14:58 2025 +0100
Commit:     Eric Kohl <eric.k...@reactos.org>
CommitDate: Sun Mar 16 14:14:58 2025 +0100

    [SYSETUP] Set the tcpip service hostname parameter even if the service key 
does not exist yet
---
 dll/win32/syssetup/wizard.c | 45 +++++++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/dll/win32/syssetup/wizard.c b/dll/win32/syssetup/wizard.c
index 0345ed14f40..ade3c295a3f 100644
--- a/dll/win32/syssetup/wizard.c
+++ b/dll/win32/syssetup/wizard.c
@@ -937,30 +937,35 @@ WriteComputerSettings(WCHAR * ComputerName, HWND hwndDlg)
     SetAccountsDomainSid(NULL, ComputerName);
 
     /* Now we need to set the Hostname */
-    lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
-                           
L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
-                           0,
-                           KEY_SET_VALUE,
-                           &hKey);
-    if (lError != ERROR_SUCCESS)
-    {
-        DPRINT1("RegOpenKeyExW for Tcpip\\Parameters failed (%08lX)\n", 
lError);
-        return TRUE;
-    }
+    lError = RegCreateKeyExW(HKEY_LOCAL_MACHINE,
+                             
L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
+                             0,
+                             NULL,
+                             REG_OPTION_NON_VOLATILE,
+                             KEY_WRITE,
+                             NULL,
+                             &hKey,
+                             NULL);
+    if (lError == ERROR_SUCCESS)
+    {
+        lError = RegSetValueEx(hKey,
+                               L"Hostname",
+                               0,
+                               REG_SZ,
+                               (LPBYTE)ComputerName,
+                               (wcslen(ComputerName) + 1) * sizeof(WCHAR));
+        if (lError != ERROR_SUCCESS)
+        {
+            DPRINT1("RegSetValueEx(\"Hostname\") failed (%08lX)\n", lError);
+        }
 
-    lError = RegSetValueEx(hKey,
-                           L"Hostname",
-                           0,
-                           REG_SZ,
-                           (LPBYTE)ComputerName,
-                           (wcslen(ComputerName) + 1) * sizeof(WCHAR));
-    if (lError != ERROR_SUCCESS)
+        RegCloseKey(hKey);
+    }
+    else
     {
-        DPRINT1("RegSetValueEx(\"Hostname\") failed (%08lX)\n", lError);
+        DPRINT1("RegCreateKeyExW for Tcpip\\Parameters failed (%08lX)\n", 
lError);
     }
 
-    RegCloseKey(hKey);
-
     return TRUE;
 }
 

Reply via email to