- hide devices if necessary
authorThomas Bluemel <thomas@reactsoft.com>
Thu, 1 Dec 2005 14:29:46 +0000 (14:29 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Thu, 1 Dec 2005 14:29:46 +0000 (14:29 +0000)
- add some (not all!) missing device node status flags to w32api

svn path=/trunk/; revision=19795

reactos/lib/devmgr/advprop.c
reactos/lib/devmgr/hwpage.c
reactos/lib/devmgr/misc.c
reactos/lib/devmgr/precomp.h
reactos/w32api/include/setupapi.h

index ed7a68a..8dc39c3 100644 (file)
@@ -228,7 +228,7 @@ DisplayDeviceAdvancedProperties(IN HWND hWndParent,
                                    sizeof(DevAdvPropInfo->szDevName) / sizeof(DevAdvPropInfo->szDevName[0])))
     {
         psh.dwSize = sizeof(PROPSHEETHEADER);
-        psh.dwFlags =  PSH_PROPTITLE;
+        psh.dwFlags = PSH_PROPTITLE;
         psh.hwndParent = hWndParent;
         psh.pszCaption = DevAdvPropInfo->szDevName;
 
index accb815..a717a52 100644 (file)
@@ -41,6 +41,7 @@ typedef struct _HWDEVINFO
 {
     struct _HWCLASSDEVINFO *ClassDevInfo;
     SP_DEVINFO_DATA DevInfoData;
+    BOOL HideDevice;
 } HWDEVINFO, *PHWDEVINFO;
 
 typedef struct _HWCLASSDEVINFO
@@ -281,7 +282,7 @@ BuildDevicesList(IN PHARDWARE_PAGE_DATA hpd)
         ClassDevInfo->hDevInfo = SetupDiGetClassDevs(&ClassDevInfo->Guid,
                                                      NULL,
                                                      hpd->hWnd,
-                                                     DIGCF_PRESENT);
+                                                     DIGCF_PRESENT | DIGCF_PROFILE);
         if (ClassDevInfo->hDevInfo != INVALID_HANDLE_VALUE)
         {
             DWORD MemberIndex = 0;
@@ -295,6 +296,8 @@ BuildDevicesList(IN PHARDWARE_PAGE_DATA hpd)
                                          MemberIndex++,
                                          &DevInfoData))
             {
+                BOOL HideDevice = FALSE;
+
                 if (ClassDevInfo->HwDevInfo != NULL)
                 {
                     PHWDEVINFO HwNewDevInfo = HeapReAlloc(GetProcessHeap(),
@@ -325,9 +328,15 @@ BuildDevicesList(IN PHARDWARE_PAGE_DATA hpd)
                     }
                 }
 
+                /* Find out if the device should be hidden by default */
+                IsDeviceHidden(DevInfoData.DevInst,
+                               NULL,
+                               &HideDevice);
+
                 /* save all information for the current device */
                 ClassDevInfo->HwDevInfo[ClassDevInfo->ItemCount].ClassDevInfo = ClassDevInfo;
-                ClassDevInfo->HwDevInfo[ClassDevInfo->ItemCount++].DevInfoData = DevInfoData;
+                ClassDevInfo->HwDevInfo[ClassDevInfo->ItemCount].DevInfoData = DevInfoData;
+                ClassDevInfo->HwDevInfo[ClassDevInfo->ItemCount++].HideDevice = HideDevice;
             }
         }
 
@@ -362,7 +371,8 @@ FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd)
                 LVITEM li;
 
                 /* get the device name */
-                if (GetDeviceDescriptionString(ClassDevInfo->hDevInfo,
+                if (!HwDevInfo->HideDevice &&
+                    GetDeviceDescriptionString(ClassDevInfo->hDevInfo,
                                                &HwDevInfo->DevInfoData,
                                                szBuffer,
                                                sizeof(szBuffer) / sizeof(szBuffer[0])))
index 94f1859..b87ff5a 100644 (file)
@@ -97,32 +97,42 @@ AllocAndLoadString(OUT LPWSTR *lpTarget,
 static INT
 AllocAndLoadStringsCat(OUT LPWSTR *lpTarget,
                        IN HINSTANCE hInst,
-                       IN UINT uID1,
-                       IN UINT uID2)
+                       IN UINT *uID,
+                       IN UINT nIDs)
 {
-    INT ln;
+    INT ln = 0;
+    UINT i;
 
-    ln = LengthOfStrResource(hInst,
-                             uID1);
-    ln += LengthOfStrResource(hInst,
-                              uID2);
-    if (ln++ > 0)
+    for (i = 0;
+         i != nIDs;
+         i++)
+    {
+        ln += LengthOfStrResource(hInst,
+                                  uID[i]);
+    }
+
+    if (ln != 0)
     {
         (*lpTarget) = (LPWSTR)LocalAlloc(LMEM_FIXED,
-                                         ln * sizeof(WCHAR));
+                                         (ln + 1) * sizeof(WCHAR));
         if ((*lpTarget) != NULL)
         {
-            INT Ret, Ret2 = 0;
-            if (!(Ret = LoadStringW(hInst, uID1, *lpTarget, ln)))
-            {
-                LocalFree((HLOCAL)(*lpTarget));
-            }
-            else if (!(Ret2 = LoadStringW(hInst, uID2, *lpTarget + Ret, ln - Ret)))
+            LPWSTR s = *lpTarget;
+            INT Ret = 0;
+
+            for (i = 0;
+                 i != nIDs;
+                 i++)
             {
-                LocalFree((HLOCAL)(*lpTarget));
-                Ret = 0;
+                if (!(Ret = LoadStringW(hInst, uID[i], s, ln)))
+                {
+                    LocalFree((HLOCAL)(*lpTarget));
+                }
+
+                s += Ret;
             }
-            return Ret + Ret2;
+
+            return s - *lpTarget;
         }
     }
     return 0;
@@ -141,7 +151,7 @@ LoadAndFormatString(IN HINSTANCE hInstance,
 
     if (AllocAndLoadString(&lpFormat,
                            hInstance,
-                           uID) > 0)
+                           uID) != 0)
     {
         va_start(lArgs, lpTarget);
         /* let's use FormatMessage to format it because it has the ability to allocate
@@ -164,8 +174,8 @@ LoadAndFormatString(IN HINSTANCE hInstance,
 
 DWORD
 LoadAndFormatStringsCat(IN HINSTANCE hInstance,
-                        IN UINT uID1,
-                        IN UINT uID2,
+                        IN UINT *uID,
+                        IN UINT nIDs,
                         OUT LPWSTR *lpTarget,
                         ...)
 {
@@ -175,8 +185,8 @@ LoadAndFormatStringsCat(IN HINSTANCE hInstance,
 
     if (AllocAndLoadStringsCat(&lpFormat,
                                hInstance,
-                               uID1,
-                               uID2) > 0)
+                               uID,
+                               nIDs) != 0)
     {
         va_start(lArgs, lpTarget);
         /* let's use FormatMessage to format it because it has the ability to allocate
@@ -458,10 +468,15 @@ GetDeviceStatusString(IN DEVINST DevInst,
         else
         {
             LPWSTR szProblem;
+            UINT StringIDs[] =
+            {
+                MessageId,
+                IDS_DEVCODE,
+            };
 
             if (LoadAndFormatStringsCat(hDllInstance,
-                                        MessageId,
-                                        IDS_DEVCODE,
+                                        StringIDs,
+                                        sizeof(StringIDs) / sizeof(StringIDs[0]),
                                         &szProblem,
                                         ProblemNumber))
             {
@@ -492,6 +507,41 @@ UnknownProblem:
 }
 
 
+BOOL
+IsDeviceHidden(IN DEVINST DevInst,
+               IN HANDLE hMachine,
+               OUT BOOL *IsHidden)
+{
+    CONFIGRET cr;
+    ULONG Status, ProblemNumber;
+    BOOL Ret = FALSE;
+
+    if (hMachine != NULL)
+    {
+        cr = CM_Get_DevNode_Status_Ex(&Status,
+                                      &ProblemNumber,
+                                      DevInst,
+                                      0,
+                                      hMachine);
+    }
+    else
+    {
+        cr = CM_Get_DevNode_Status(&Status,
+                                   &ProblemNumber,
+                                   DevInst,
+                                   0);
+    }
+
+    if (cr == CR_SUCCESS)
+    {
+        *IsHidden = ((Status & DN_NO_SHOW_IN_DM) != 0);
+        Ret = TRUE;
+    }
+
+    return Ret;
+}
+
+
 BOOL
 GetDeviceTypeString(IN PSP_DEVINFO_DATA DeviceInfoData,
                     OUT LPWSTR szBuffer,
index bf15b0d..b00362d 100644 (file)
@@ -199,8 +199,8 @@ LoadAndFormatString(IN HINSTANCE hInstance,
 
 DWORD
 LoadAndFormatStringsCat(IN HINSTANCE hInstance,
-                        IN UINT uID1,
-                        IN UINT uID2,
+                        IN UINT *uID,
+                        IN UINT nIDs,
                         OUT LPWSTR *lpTarget,
                         ...);
 
@@ -231,6 +231,11 @@ GetDeviceStatusString(IN DEVINST DevInst,
                       OUT LPWSTR szBuffer,
                       IN DWORD BufferSize);
 
+BOOL
+IsDeviceHidden(IN DEVINST DevInst,
+               IN HANDLE hMachine,
+               OUT BOOL *IsHidden);
+
 BOOL
 GetDeviceTypeString(IN PSP_DEVINFO_DATA DeviceInfoData,
                     OUT LPWSTR szBuffer,
index f65e16b..88144d3 100644 (file)
@@ -212,6 +212,13 @@ extern "C" {
 #define DMI_MASK       0x00000001
 #define DMI_BKCOLOR    0x00000002
 #define DMI_USERECT    0x00000004
+#define DN_NEEDS_LOCKING       0x02000000
+#define DN_ARM_WAKEUP  0x04000000
+#define DN_APM_ENUMERATOR      0x08000000
+#define DN_APM_DRIVER  0x10000000
+#define DN_SILENT_INSTALL      0x20000000
+#define DN_NO_SHOW_IN_DM       0x40000000
+#define DN_BOOT_LOG_PROB       0x80000000
 #define DNF_DUPDESC    0x00000001
 #define DNF_OLDDRIVER  0x00000002
 #define DNF_EXCLUDEFROMLIST    0x00000004