[DEVMGMT]
authorEric Kohl <eric.kohl@reactos.org>
Thu, 22 Mar 2012 22:38:06 +0000 (22:38 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 22 Mar 2012 22:38:06 +0000 (22:38 +0000)
Implement the "Show hidden devices" feature.

svn path=/trunk/; revision=56214

24 files changed:
reactos/base/applications/mscutils/devmgmt/enumdevices.c
reactos/base/applications/mscutils/devmgmt/lang/bg-BG.rc
reactos/base/applications/mscutils/devmgmt/lang/cs-CZ.rc
reactos/base/applications/mscutils/devmgmt/lang/de-DE.rc
reactos/base/applications/mscutils/devmgmt/lang/el-GR.rc
reactos/base/applications/mscutils/devmgmt/lang/en-US.rc
reactos/base/applications/mscutils/devmgmt/lang/es-ES.rc
reactos/base/applications/mscutils/devmgmt/lang/fr-FR.rc
reactos/base/applications/mscutils/devmgmt/lang/id-ID.rc
reactos/base/applications/mscutils/devmgmt/lang/it-IT.rc
reactos/base/applications/mscutils/devmgmt/lang/ja-JP.rc
reactos/base/applications/mscutils/devmgmt/lang/ko-KR.rc
reactos/base/applications/mscutils/devmgmt/lang/no-NO.rc
reactos/base/applications/mscutils/devmgmt/lang/pl-PL.rc
reactos/base/applications/mscutils/devmgmt/lang/ro-RO.rc
reactos/base/applications/mscutils/devmgmt/lang/ru-RU.rc
reactos/base/applications/mscutils/devmgmt/lang/sk-SK.rc
reactos/base/applications/mscutils/devmgmt/lang/sv-SE.rc
reactos/base/applications/mscutils/devmgmt/lang/th-TH.rc
reactos/base/applications/mscutils/devmgmt/lang/uk-UA.rc
reactos/base/applications/mscutils/devmgmt/lang/zh-CN.rc
reactos/base/applications/mscutils/devmgmt/mainwnd.c
reactos/base/applications/mscutils/devmgmt/precomp.h
reactos/base/applications/mscutils/devmgmt/resource.h

index 5ac50b0..7978ef5 100644 (file)
@@ -136,11 +136,13 @@ InsertIntoTreeView(HWND hTreeView,
 
 static INT
 EnumDeviceClasses(INT ClassIndex,
+                  BOOL ShowHidden,
                   LPTSTR DevClassName,
                   LPTSTR DevClassDesc,
                   BOOL *DevPresent,
                   INT *ClassImage,
-                  BOOL *IsUnknown)
+                  BOOL *IsUnknown,
+                  BOOL *IsHidden)
 {
     GUID ClassGuid;
     HKEY KeyClass;
@@ -150,6 +152,7 @@ EnumDeviceClasses(INT ClassIndex,
 
     *DevPresent = FALSE;
     *DevClassName = _T('\0');
+    *IsHidden = FALSE;
 
     Ret = CM_Enumerate_Classes(ClassIndex,
                                &ClassGuid,
@@ -173,6 +176,11 @@ EnumDeviceClasses(INT ClassIndex,
     /* This case is special because these devices don't show up with normal class enumeration */
     *IsUnknown = IsEqualGUID(&ClassGuid, &GUID_DEVCLASS_UNKNOWN);
 
+    if (ShowHidden == FALSE &&
+        (IsEqualGUID(&ClassGuid, &GUID_DEVCLASS_LEGACYDRIVER) ||
+         IsEqualGUID(&ClassGuid, &GUID_DEVCLASS_VOLUME)))
+        *IsHidden = TRUE;
+
     if (SetupDiClassNameFromGuid(&ClassGuid,
                                  ClassName,
                                  RequiredSize,
@@ -327,7 +335,8 @@ EnumDevices(INT index,
 
 VOID
 ListDevicesByType(HWND hTreeView,
-                  HTREEITEM hRoot)
+                  HTREEITEM hRoot,
+                  BOOL bShowHidden)
 {
     HTREEITEM hDevItem;
     TCHAR DevName[MAX_DEV_LEN];
@@ -338,17 +347,20 @@ ListDevicesByType(HWND hTreeView,
     INT index = 0;
     INT DevImage;
     BOOL IsUnknown = FALSE;
+    BOOL IsHidden = FALSE;
 
     do
     {
         ClassRet = EnumDeviceClasses(index,
+                                     bShowHidden,
                                      DevName,
                                      DevDesc,
                                      &DevExist,
                                      &DevImage,
-                                     &IsUnknown);
+                                     &IsUnknown,
+                                     &IsHidden);
 
-        if ((ClassRet != -1) && (DevExist))
+        if ((ClassRet != -1) && (DevExist) && !IsHidden)
         {
             TCHAR DeviceName[MAX_DEV_LEN];
             INT DevIndex = 0;
@@ -442,7 +454,8 @@ ListDevicesByType(HWND hTreeView,
 static HTREEITEM
 AddDeviceToTree(HWND hTreeView,
                 HTREEITEM hRoot,
-                DEVINST dnDevInst)
+                DEVINST dnDevInst,
+                BOOL bShowHidden)
 {
     TCHAR DevName[MAX_DEV_LEN];
     TCHAR FriendlyName[MAX_DEV_LEN];
@@ -453,6 +466,28 @@ AddDeviceToTree(HWND hTreeView,
     INT ClassImage = 24;
     CONFIGRET cr;
 
+    ulLength = MAX_GUID_STRING_LEN * sizeof(TCHAR);
+    cr = CM_Get_DevNode_Registry_Property(dnDevInst,
+                                          CM_DRP_CLASSGUID,
+                                          NULL,
+                                          ClassGuidString,
+                                          &ulLength,
+                                          0);
+    if (cr == CR_SUCCESS)
+    {
+        pSetupGuidFromString(ClassGuidString, &ClassGuid);
+
+        if (bShowHidden == FALSE &&
+            (IsEqualGUID(&ClassGuid, &GUID_DEVCLASS_LEGACYDRIVER) ||
+             IsEqualGUID(&ClassGuid, &GUID_DEVCLASS_VOLUME)))
+            return NULL;
+    }
+    else
+    {
+        /* It's a device with no driver */
+        ClassGuid = GUID_DEVCLASS_UNKNOWN;
+    }
+
     cr = CM_Get_Device_ID(dnDevInst,
                           DevName,
                           MAX_DEV_LEN,
@@ -480,23 +515,6 @@ AddDeviceToTree(HWND hTreeView,
             return NULL;
     }
 
-    ulLength = MAX_GUID_STRING_LEN * sizeof(TCHAR);
-    cr = CM_Get_DevNode_Registry_Property(dnDevInst,
-                                          CM_DRP_CLASSGUID,
-                                          NULL,
-                                          ClassGuidString,
-                                          &ulLength,
-                                          0);
-    if (cr == CR_SUCCESS)
-    {
-        pSetupGuidFromString(ClassGuidString, &ClassGuid);
-    }
-    else
-    {
-        /* It's a device with no driver */
-        ClassGuid = GUID_DEVCLASS_UNKNOWN;
-    }
-
     if (!SetupDiGetClassImageIndex(&ImageListData,
                                    &ClassGuid,
                                    &ClassImage))
@@ -532,7 +550,8 @@ AddDeviceToTree(HWND hTreeView,
 static VOID
 EnumChildDevices(HWND hTreeView,
                  HTREEITEM hRoot,
-                 DEVINST dnParentDevInst)
+                 DEVINST dnParentDevInst,
+                 BOOL bShowHidden)
 {
     HTREEITEM hDevItem;
     DEVINST dnDevInst;
@@ -546,13 +565,15 @@ EnumChildDevices(HWND hTreeView,
 
     hDevItem = AddDeviceToTree(hTreeView,
                                hRoot,
-                               dnDevInst);
-    if (hDevItem == NULL)
-        return;
-
-    EnumChildDevices(hTreeView,
-                     hDevItem,
-                     dnDevInst);
+                               dnDevInst,
+                               bShowHidden);
+    if (hDevItem != NULL)
+    {
+        EnumChildDevices(hTreeView,
+                         hDevItem,
+                         dnDevInst,
+                         bShowHidden);
+    }
 
     while (cr == CR_SUCCESS)
     {
@@ -564,13 +585,15 @@ EnumChildDevices(HWND hTreeView,
 
         hDevItem = AddDeviceToTree(hTreeView,
                                    hRoot,
-                                   dnDevInst);
-        if (hDevItem == NULL)
-            break;
-
-        EnumChildDevices(hTreeView,
-                         hDevItem,
-                         dnDevInst);
+                                   dnDevInst,
+                                   bShowHidden);
+        if (hDevItem != NULL)
+        {
+            EnumChildDevices(hTreeView,
+                             hDevItem,
+                             dnDevInst,
+                             bShowHidden);
+        }
     }
 
     (void)TreeView_SortChildren(hTreeView,
@@ -581,7 +604,8 @@ EnumChildDevices(HWND hTreeView,
 
 VOID
 ListDevicesByConnection(HWND hTreeView,
-                        HTREEITEM hRoot)
+                        HTREEITEM hRoot,
+                        BOOL bShowHidden)
 {
     DEVINST devInst;
     CONFIGRET cr;
@@ -592,7 +616,8 @@ ListDevicesByConnection(HWND hTreeView,
     if (cr == CR_SUCCESS)
         EnumChildDevices(hTreeView,
                          hRoot,
-                         devInst);
+                         devInst,
+                         bShowHidden);
 
     (void)TreeView_Expand(hTreeView,
                           hRoot,
index dd7feb6..2fb7502 100644 (file)
@@ -20,6 +20,8 @@ BEGIN
     MENUITEM "Устройствата според свързването",   IDC_DEVBYCONN
     MENUITEM "Средствата според вида",       IDC_RESBYTYPE, GRAYED
     MENUITEM "Средствата според свързването", IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",     IDC_SHOWHIDDEN
   END
   POPUP "Помощ"
   BEGIN
index c1661ed..da106b4 100644 (file)
@@ -20,6 +20,8 @@ BEGIN
     MENUITEM "Zařízení podle připojení",   IDC_DEVBYCONN
     MENUITEM "Prostředky podle typu",      IDC_RESBYTYPE, GRAYED
     MENUITEM "Prostředky podle připojení", IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",        IDC_SHOWHIDDEN
   END
   POPUP "Nápověda"
   BEGIN
index 599597a..fa35ce1 100644 (file)
@@ -1,4 +1,4 @@
-LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
+LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
 
 IDR_MAINMENU MENU
 BEGIN
@@ -20,6 +20,8 @@ BEGIN
     MENUITEM "Geräte nach Verbindung",    IDC_DEVBYCONN
     MENUITEM "Resourcen nach Typ",        IDC_RESBYTYPE, GRAYED
     MENUITEM "Resourcen nach Verbindung", IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Ausgeblendete Geräte anzeigen", IDC_SHOWHIDDEN
   END
   POPUP "&?"
   BEGIN
index 97ea1b2..de9feac 100644 (file)
@@ -20,6 +20,8 @@ BEGIN
     MENUITEM "Συσκευές ανά σύνδεση", IDC_DEVBYCONN
     MENUITEM "Πηγές ανά τύπο",       IDC_RESBYTYPE, GRAYED
     MENUITEM "Πηγές ανά σύνδεση",    IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",  IDC_SHOWHIDDEN
   END
   POPUP "Βοήθεια"
   BEGIN
index dad497e..53b072c 100644 (file)
@@ -20,6 +20,8 @@ BEGIN
     MENUITEM "Devices by connection",   IDC_DEVBYCONN
     MENUITEM "Resources by type",       IDC_RESBYTYPE, GRAYED
     MENUITEM "Resources by connection", IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",     IDC_SHOWHIDDEN
   END
   POPUP "Help"
   BEGIN
index e524027..d9a70f7 100644 (file)
@@ -25,6 +25,8 @@ BEGIN
     MENUITEM "Dispositivos por conexión", IDC_DEVBYCONN
     MENUITEM "Recursos por tipo",         IDC_RESBYTYPE, GRAYED
     MENUITEM "Recursos por conexión",     IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",       IDC_SHOWHIDDEN
   END
   POPUP "Ayuda"
   BEGIN
index c3130eb..b4955f4 100644 (file)
@@ -20,6 +20,8 @@ BEGIN
     MENUITEM "Périphériques par connexion", IDC_DEVBYCONN
     MENUITEM "Ressources par type",         IDC_RESBYTYPE, GRAYED
     MENUITEM "Ressources par connexion",    IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",         IDC_SHOWHIDDEN
   END
   POPUP "Aide"
   BEGIN
index ce2e89e..c91207e 100644 (file)
@@ -20,6 +20,8 @@ BEGIN
     MENUITEM "Device dengan koneksi",   IDC_DEVBYCONN
     MENUITEM "Resource dengan tipe",    IDC_RESBYTYPE, GRAYED
     MENUITEM "Resource dengan koneksi", IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",     IDC_SHOWHIDDEN
   END
   POPUP "Bantuan"
   BEGIN
index 4124e97..e918c5f 100644 (file)
@@ -20,6 +20,8 @@ BEGIN
     MENUITEM "Dispositivi per connessione", IDC_DEVBYCONN
     MENUITEM "Risorse per tipo",            IDC_RESBYTYPE, GRAYED
     MENUITEM "Risorse per connessione",     IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",         IDC_SHOWHIDDEN
   END
   POPUP "Aiuto"
   BEGIN
index 0c67d9d..77c2c38 100644 (file)
@@ -20,6 +20,8 @@ BEGIN
     MENUITEM "デバイス (接続別)",       IDC_DEVBYCONN
     MENUITEM "リソ ース (種類別)",      IDC_RESBYTYPE, GRAYED
     MENUITEM "リソ ース (接続別)",      IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices", IDC_SHOWHIDDEN
   END
   POPUP "ヘルプ"
   BEGIN
index c661fcf..fe1f77e 100644 (file)
@@ -24,6 +24,8 @@ BEGIN
     MENUITEM "Devices by connection",   IDC_DEVBYCONN
     MENUITEM "Resources by type",       IDC_RESBYTYPE, GRAYED
     MENUITEM "Resources by connection", IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",     IDC_SHOWHIDDEN
   END
   POPUP "도움말"
   BEGIN
index 2fd1fff..2646ec1 100644 (file)
@@ -20,6 +20,8 @@ BEGIN
     MENUITEM "Enheter etter tilkobling",   IDC_DEVBYCONN
     MENUITEM "Ressurser etter type",       IDC_RESBYTYPE, GRAYED
     MENUITEM "Ressurser etter tilkobling", IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",        IDC_SHOWHIDDEN
   END
   POPUP "Hjelp"
   BEGIN
index b0dbdf9..3f36f57 100644 (file)
@@ -27,6 +27,8 @@ BEGIN
     MENUITEM "Ur&ządzenia według połączenia", IDC_DEVBYCONN
     MENUITEM "Zaso&by według typu",           IDC_RESBYTYPE, GRAYED
     MENUITEM "Za&soby według połączenia",     IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",           IDC_SHOWHIDDEN
   END
   POPUP "Pomo&c"
   BEGIN
index 59bc162..975db63 100644 (file)
@@ -21,6 +21,8 @@ BEGIN
     MENUITEM "Dispozitive după &conexiune",   IDC_DEVBYCONN
     MENUITEM "Resurse după t&ip",             IDC_RESBYTYPE, GRAYED
     MENUITEM "Resurse după c&onexiune",       IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",           IDC_SHOWHIDDEN
   END
   POPUP "&?"
   BEGIN
index a820b2d..3e7bf3e 100644 (file)
@@ -22,6 +22,8 @@ BEGIN
     MENUITEM "Устройства по подключению", IDC_DEVBYCONN
     MENUITEM "Ресурсы по типу",           IDC_RESBYTYPE, GRAYED
     MENUITEM "Ресурсы по подключению",    IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",       IDC_SHOWHIDDEN
   END
   POPUP "Справка"
   BEGIN
index 3ad03e8..c888c8f 100644 (file)
@@ -25,6 +25,8 @@ BEGIN
     MENUITEM "Zariadenia podľa pripojenia",  IDC_DEVBYCONN
     MENUITEM "Prostriedky podľa typu",       IDC_RESBYTYPE, GRAYED
     MENUITEM "Prostriedky podľa pripojenia", IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",          IDC_SHOWHIDDEN
   END
   POPUP "Pomocník"
   BEGIN
index e92c6ab..7bd07b5 100644 (file)
@@ -27,6 +27,8 @@ BEGIN
     MENUITEM "Enheter efter koppling",  IDC_DEVBYCONN
     MENUITEM "Resurcer efter typ",      IDC_RESBYTYPE, GRAYED
     MENUITEM "Resurcer efter koppling", IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",     IDC_SHOWHIDDEN
   END
   POPUP "Hjälp"
   BEGIN
index afcc06f..b2c1289 100644 (file)
@@ -28,6 +28,8 @@ BEGIN
     MENUITEM "อุปกรณ์แบ่งตามการเชื่อมต่อ",   IDC_DEVBYCONN
     MENUITEM "แหล่งข้อมูลตามประเภท",         IDC_RESBYTYPE, GRAYED
     MENUITEM "แหล่งข้อมูลตามการเชื่อมต่อ",   IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",          IDC_SHOWHIDDEN
   END
   POPUP "ช่วยเหลือ"
   BEGIN
index 1a5f1e7..3b9e8fd 100644 (file)
@@ -28,6 +28,8 @@ BEGIN
     MENUITEM "Пристрої за підключенням", IDC_DEVBYCONN
     MENUITEM "Ресурси за типом",         IDC_RESBYTYPE, GRAYED
     MENUITEM "Ресурси за підключенням",  IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices",      IDC_SHOWHIDDEN
   END
   POPUP "Довідка"
   BEGIN
index 71b508a..6ef4fc4 100644 (file)
@@ -24,6 +24,8 @@ BEGIN
     MENUITEM "设备,按连接",              IDC_DEVBYCONN
     MENUITEM "资源,按类型",              IDC_RESBYTYPE, GRAYED
     MENUITEM "资源,按连接",              IDC_RESBYCONN, GRAYED
+    MENUITEM SEPARATOR
+    MENUITEM "Show hidden devices", IDC_SHOWHIDDEN
   END
   POPUP "帮助"
   BEGIN
index f6a5313..63218d9 100644 (file)
@@ -217,11 +217,11 @@ DeviceEnumThread(LPVOID lpParameter)
         switch (Info->Display)
         {
             case DevicesByType:
-                ListDevicesByType(Info->hTreeView, hRoot);
+                ListDevicesByType(Info->hTreeView, hRoot, Info->bShowHidden);
                 break;
 
             case DevicesByConnection:
-                ListDevicesByConnection(Info->hTreeView, hRoot);
+                ListDevicesByConnection(Info->hTreeView, hRoot, Info->bShowHidden);
                 break;
 
             default:
@@ -238,6 +238,9 @@ static VOID
 UpdateViewMenu(PMAIN_WND_INFO Info)
 {
     UINT id = IDC_DEVBYTYPE;
+    HMENU hMenu;
+
+    hMenu = GetMenu(Info->hMainWnd);
 
     switch (Info->Display)
     {
@@ -255,11 +258,15 @@ UpdateViewMenu(PMAIN_WND_INFO Info)
             break;
     }
 
-    CheckMenuRadioItem(GetMenu(Info->hMainWnd),
+    CheckMenuRadioItem(hMenu,
                        IDC_DEVBYTYPE,
                        IDC_RESBYCONN,
                        id,
                        MF_BYCOMMAND);
+
+    CheckMenuItem(hMenu,
+                  IDC_SHOWHIDDEN,
+                  MF_BYCOMMAND | (Info->bShowHidden) ? MF_CHECKED : MF_UNCHECKED);
 }
 
 
@@ -598,6 +605,14 @@ MainWndCommand(PMAIN_WND_INFO Info,
             OnRefresh(Info);
         }
         break;
+
+        case IDC_SHOWHIDDEN:
+        {
+            Info->bShowHidden = !Info->bShowHidden;
+            UpdateViewMenu(Info);
+            OnRefresh(Info);
+        }
+        break;
     }
 }
 
@@ -794,6 +809,7 @@ CreateMainWindow(LPCTSTR lpCaption,
     {
         Info->nCmdShow = nCmdShow;
         Info->Display = DevicesByType;
+        Info->bShowHidden = TRUE;
 
         hMainWnd = CreateWindowEx(WS_EX_WINDOWEDGE,
                                   szMainWndClass,
index 2276bfd..5a4a908 100644 (file)
@@ -40,6 +40,7 @@ typedef struct _MAIN_WND_INFO
     int   nCmdShow;
 
     DISPLAY_TYPE Display;
+    BOOL bShowHidden;
 
     /* status flags */
     UINT InMenuLoop : 1;
@@ -71,8 +72,8 @@ HWND CreateMainWindow(LPCTSTR lpCaption, int nCmdShow);
 VOID FreeDeviceStrings(HWND hTreeView);
 VOID OpenPropSheet(HWND hTreeView, HTREEITEM hItem);
 HTREEITEM InitTreeView(HWND hTreeView);
-VOID ListDevicesByType(HWND hTreeView, HTREEITEM hRoot);
-VOID ListDevicesByConnection(HWND hTreeView, HTREEITEM hRoot);
+VOID ListDevicesByType(HWND hTreeView, HTREEITEM hRoot, BOOL bShowHidden);
+VOID ListDevicesByConnection(HWND hTreeView, HTREEITEM hRoot, BOOL bShowHidden);
 
 
 /* misc.c */
index 2f67d6c..65b756b 100644 (file)
@@ -23,6 +23,7 @@
 #define IDC_DEVBYCONN       105
 #define IDC_RESBYTYPE       106
 #define IDC_RESBYCONN       107
+#define IDC_SHOWHIDDEN      108
 
 /* tooltips */
 #define IDS_TOOLTIP_PROP    6000