@@ -937,30 +937,35 @@ WriteComputerSettings(WCHAR * ComputerName, HWND hwndDlg)
937937 SetAccountsDomainSid (NULL , ComputerName );
938938
939939 /* Now we need to set the Hostname */
940- lError = RegOpenKeyExW (HKEY_LOCAL_MACHINE ,
941- L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters" ,
942- 0 ,
943- KEY_SET_VALUE ,
944- & hKey );
945- if (lError != ERROR_SUCCESS )
946- {
947- DPRINT1 ("RegOpenKeyExW for Tcpip\\Parameters failed (%08lX)\n" , lError );
948- return TRUE;
949- }
940+ lError = RegCreateKeyExW (HKEY_LOCAL_MACHINE ,
941+ L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters" ,
942+ 0 ,
943+ NULL ,
944+ REG_OPTION_NON_VOLATILE ,
945+ KEY_WRITE ,
946+ NULL ,
947+ & hKey ,
948+ NULL );
949+ if (lError == ERROR_SUCCESS )
950+ {
951+ lError = RegSetValueEx (hKey ,
952+ L"Hostname" ,
953+ 0 ,
954+ REG_SZ ,
955+ (LPBYTE )ComputerName ,
956+ (wcslen (ComputerName ) + 1 ) * sizeof (WCHAR ));
957+ if (lError != ERROR_SUCCESS )
958+ {
959+ DPRINT1 ("RegSetValueEx(\"Hostname\") failed (%08lX)\n" , lError );
960+ }
950961
951- lError = RegSetValueEx (hKey ,
952- L"Hostname" ,
953- 0 ,
954- REG_SZ ,
955- (LPBYTE )ComputerName ,
956- (wcslen (ComputerName ) + 1 ) * sizeof (WCHAR ));
957- if (lError != ERROR_SUCCESS )
962+ RegCloseKey (hKey );
963+ }
964+ else
958965 {
959- DPRINT1 ("RegSetValueEx(\"Hostname\") failed (%08lX)\n" , lError );
966+ DPRINT1 ("RegCreateKeyExW for Tcpip\\Parameters failed (%08lX)\n" , lError );
960967 }
961968
962- RegCloseKey (hKey );
963-
964969 return TRUE;
965970}
966971
0 commit comments