[SETUPAPI] Create device interface related keys in case they don't exist yet (#9283)

In SetupDiCreateDeviceInterfaceRegKeyW(), force creating device and reference subkeys of device interface in Registry if they are not created yet.
- Change RegOpenKeyExW() to RegCreateKeyExW() for device and reference subkeys.
This properly fixes audio device name string improperly set in registry and displaying audio device name system-wide. Now it's properly written not only after re-installing audio driver from Device Manager, but also during 2nd setup stage, so it's correct just right after 1st boot.
Addendum to 1ef584c446 and b205c04173.
CORE-20603
This commit is contained in:
Oleg Dubinskiy
2026-07-13 11:25:15 +02:00
committed by GitHub
parent 46e69e6e50
commit 02d7bbc54d
+4 -4
View File
@@ -2716,8 +2716,8 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(
* as we don't need a ref part in key name. */
SymbolicLink[Index + 1] = UNICODE_NULL;
/* Open device instance key */
rc = RegOpenKeyExW(hKey, SymbolicLink, 0, samDesired, &hDevKey);
/* Create device instance key */
rc = RegCreateKeyExW(hKey, SymbolicLink, 0, NULL, 0, samDesired, NULL, &hDevKey, NULL);
HeapFree(GetProcessHeap(), 0, SymbolicLink);
RegCloseKey(hKey);
if (rc != ERROR_SUCCESS)
@@ -2727,8 +2727,8 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(
return INVALID_HANDLE_VALUE;
}
/* Open reference key */
rc = RegOpenKeyExW(hDevKey, ReferenceString, 0, samDesired, &hRefKey);
/* Create reference key */
rc = RegCreateKeyExW(hDevKey, ReferenceString, 0, NULL, 0, samDesired, NULL, &hRefKey, NULL);
HeapFree(GetProcessHeap(), 0, ReferenceString);
RegCloseKey(hDevKey);
if (rc != ERROR_SUCCESS)