[KSPROXY]
[reactos.git] / reactos / dll / cpl / desk / classinst.c
index 1221925..0cdb70c 100644 (file)
@@ -7,11 +7,11 @@
  * PROGRAMMERS:     HervĂ© Poussineau (hpoussin@reactos.org)
  */
 
+#include "desk.h"
+
 //#define NDEBUG
 #include <debug.h>
 
-#include "desk.h"
-
 DWORD WINAPI
 DisplayClassInstaller(
        IN DI_FUNCTION InstallFunction,
@@ -24,11 +24,11 @@ DisplayClassInstaller(
        TCHAR SectionName[MAX_PATH];
        TCHAR ServiceName[MAX_SERVICE_NAME_LEN];
        SP_DRVINFO_DETAIL_DATA DriverInfoDetailData;
-       HKEY hDriverKey = INVALID_HANDLE_VALUE;
-       HKEY hSettingsKey = INVALID_HANDLE_VALUE;
-       HKEY hServicesKey = INVALID_HANDLE_VALUE;
-       HKEY hServiceKey = INVALID_HANDLE_VALUE;
-       HKEY hDeviceSubKey = INVALID_HANDLE_VALUE;
+       HKEY hDriverKey = INVALID_HANDLE_VALUE; /* SetupDiOpenDevRegKey returns INVALID_HANDLE_VALUE in case of error! */
+       HKEY hSettingsKey = NULL;
+       HKEY hServicesKey = NULL;
+       HKEY hServiceKey = NULL;
+       HKEY hDeviceSubKey = NULL;
        DWORD disposition;
        BOOL result;
        LONG rc;
@@ -119,7 +119,7 @@ DisplayClassInstaller(
        }
        rc = RegCreateKeyEx(
                hDriverKey, L"Settings",
-               0, NULL, REG_OPTION_NON_VOLATILE, 
+               0, NULL, REG_OPTION_NON_VOLATILE,
 #if _WIN32_WINNT >= 0x502
                KEY_READ | KEY_WRITE,
 #else
@@ -214,14 +214,17 @@ cleanup:
        if (hInf != INVALID_HANDLE_VALUE)
                SetupCloseInfFile(hInf);
        if (hDriverKey != INVALID_HANDLE_VALUE)
+       {
+               /* SetupDiOpenDevRegKey returns INVALID_HANDLE_VALUE in case of error! */
                RegCloseKey(hDriverKey);
-       if (hSettingsKey != INVALID_HANDLE_VALUE)
+       }
+       if (hSettingsKey != NULL)
                RegCloseKey(hSettingsKey);
-       if (hServicesKey != INVALID_HANDLE_VALUE)
+       if (hServicesKey != NULL)
                RegCloseKey(hServicesKey);
-       if (hServiceKey != INVALID_HANDLE_VALUE)
+       if (hServiceKey != NULL)
                RegCloseKey(hServiceKey);
-       if (hDeviceSubKey != INVALID_HANDLE_VALUE)
+       if (hDeviceSubKey != NULL)
                RegCloseKey(hDeviceSubKey);
 
        return rc;