From 02d7bbc54d20a1cb1e087038d57236122143569d Mon Sep 17 00:00:00 2001 From: Oleg Dubinskiy Date: Mon, 13 Jul 2026 11:25:15 +0200 Subject: [PATCH] [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 1ef584c44653e55b97d0de39a936fa63f36a131a and b205c041735ab98b7825461f32be8ced38c8b05e. CORE-20603 --- dll/win32/setupapi/devinst.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dll/win32/setupapi/devinst.c b/dll/win32/setupapi/devinst.c index 93fbd819b52..694d4081029 100644 --- a/dll/win32/setupapi/devinst.c +++ b/dll/win32/setupapi/devinst.c @@ -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)