Try to open driver registry key before creating it.
authorHervé Poussineau <hpoussin@reactos.org>
Sat, 12 Nov 2005 21:11:09 +0000 (21:11 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Sat, 12 Nov 2005 21:11:09 +0000 (21:11 +0000)
Fixes bug 977

svn path=/trunk/; revision=19186

reactos/lib/netcfgx/netcfgx.c

index ebf8a85..378e0ad 100644 (file)
@@ -210,7 +210,13 @@ NetClassInstaller(
        hKey = INVALID_HANDLE_VALUE;
 
        /* Write 'Linkage' key in hardware key */
-       hKey = SetupDiCreateDevRegKeyW(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DRV, NULL, NULL);
+#if _WIN32_WINNT >= 0x502
+       hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_READ | KEY_WRITE);
+#else
+       hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_ALL_ACCESS);
+#endif
+       if (hKey == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_NOT_FOUND)
+               hKey = SetupDiCreateDevRegKeyW(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DRV, NULL, NULL);
        if (hKey == INVALID_HANDLE_VALUE)
        {
                rc = GetLastError();