Example #1
0
BOOL
CDeviceView::ListDevicesByConnection()
{
    WCHAR DeviceName[DEVICE_NAME_LEN];
    INT ClassImage;
    BOOL bSuccess;

    /* Get the details of the root of the device tree */
    bSuccess = m_Devices->GetDeviceTreeRoot(DeviceName, DEVICE_NAME_LEN, &ClassImage);
    if (bSuccess)
    {
        /* Add the root of the device tree to the treeview */
        m_hTreeRoot = InsertIntoTreeView(NULL,
                                         DeviceName,
                                         NULL,
                                         ClassImage,
                                         0);
    }

    /* Walk the device tree and add all the devices */
    RecurseChildDevices(m_Devices->GetRootDevice(), m_hTreeRoot);

    /* Expand the root item */
    (VOID)TreeView_Expand(m_hTreeView,
                          m_hTreeRoot,
                          TVE_EXPAND);

    return TRUE;
}
Example #2
0
bool
CDeviceView::ListDevicesByConnection()
{
    // Walk the device tree and add all the devices 
    (void)RecurseChildDevices(m_RootNode->GetDeviceInst(), m_hTreeRoot);

    // Expand the root item 
    (void)TreeView_Expand(m_hTreeView,
                          m_hTreeRoot,
                          TVE_EXPAND);

    return true;
}
Example #3
0
bool
CDeviceView::RecurseChildDevices(
    _In_ DEVINST ParentDevice,
    _In_ HTREEITEM hParentTreeItem
    )
{
    HTREEITEM hDevItem = NULL;
    DEVINST Device;
    bool HasProblem = false;
    bool bSuccess;

    // Check if the parent has any child devices 
    if (GetChildDevice(ParentDevice, &Device) == FALSE)
        return true;

    // Get the cached device node
    CDeviceNode *DeviceNode;
    DeviceNode = dynamic_cast<CDeviceNode *>(GetDeviceNode(Device));
    if (DeviceNode == nullptr)
    {
        ATLASSERT(FALSE);
        return false;
    }

    // Don't show hidden devices if not requested
    if ((m_ShowHidden == TRUE) || (!(DeviceNode->IsHidden())))
    {
        // Add this device to the tree under its parent 
        hDevItem = InsertIntoTreeView(hParentTreeItem,
                                      DeviceNode);
        if (hDevItem)
        {
            // Check if this child has any children itself 
            if (!RecurseChildDevices(Device, hDevItem))
                HasProblem = true;
        }

        if (DeviceNode->HasProblem())
        {
            HasProblem = true;
        }
    }


    // Check for siblings
    for (;;)
    {
        // Check if the parent device has anything at the same level 
        bSuccess = GetSiblingDevice(Device, &Device);
        if (bSuccess == FALSE) break;

        DeviceNode = dynamic_cast<CDeviceNode *>(GetDeviceNode(Device));
        if (DeviceNode == nullptr)
        {
            ATLASSERT(FALSE);
        }

        // Don't show hidden devices if not requested
        if ((m_ShowHidden == TRUE) || (!(DeviceNode->IsHidden())))
        {
            if (DeviceNode->HasProblem())
            {
                HasProblem = true;
            }

            // Add this device to the tree under its parent 
            hDevItem = InsertIntoTreeView(hParentTreeItem,
                                          DeviceNode);
            if (hDevItem)
            {
                // Check if this child has any children itself 
                if (!RecurseChildDevices(Device, hDevItem))
                    HasProblem = true;
            }
        }
    }

    (void)TreeView_SortChildren(m_hTreeView,
                                hParentTreeItem,
                                0);

    // Expand the class if it has a problem device
    if (HasProblem == true)
    {
        (void)TreeView_Expand(m_hTreeView,
                              hParentTreeItem,
                              TVE_EXPAND);
    }

    // If there was a problem, expand the ancestors
    if (HasProblem) return false;

    return true;
}
Example #4
0
VOID
CDeviceView::RecurseChildDevices(
    _In_ DEVINST ParentDevice,
    _In_ HTREEITEM hParentTreeItem
    )
{
    HTREEITEM hDevItem = NULL;
    DEVINST Device;
    WCHAR DeviceName[DEVICE_NAME_LEN];
    LPTSTR DeviceId = NULL;
    INT ClassImage;
    BOOL IsUnknown = FALSE;
    BOOL IsHidden = FALSE;
    ULONG DeviceStatus = 0;
    ULONG ProblemNumber = 0;
    UINT OverlayImage = 0;
    BOOL bSuccess;

    /* Check if the parent has any child devices */
    if (m_Devices->GetChildDevice(ParentDevice, &Device) == FALSE)
        return;

    /* Lookup the info about this device */
    bSuccess = m_Devices->GetDevice(Device,
                                    DeviceName,
                                    DEVICE_NAME_LEN,
                                    &DeviceId,
                                    &ClassImage,
                                    &DeviceStatus,
                                    &ProblemNumber);
    if (bSuccess)
    {
        /* Check if this is a hidden device */
        if ((m_ShowHidden == TRUE) || (!(DeviceStatus & DN_NO_SHOW_IN_DM)))
        {
            /* Check if the device has a problem */
            if (DeviceStatus & DN_HAS_PROBLEM)
            {
                OverlayImage = 1;
            }

            /* The disabled overlay takes precidence over the problem overlay */
            if (ProblemNumber == CM_PROB_HARDWARE_DISABLED)
            {
                OverlayImage = 2;
            }

            /* Add this device to the tree under its parent */
            hDevItem = InsertIntoTreeView(hParentTreeItem,
                                          DeviceName,
                                          (LPARAM)DeviceId,
                                          ClassImage,
                                          0);


            if (hDevItem)
            {
                /* Check if this child has any children itself */
                RecurseChildDevices(Device, hDevItem);
            }
        }
    }


    for (;;)
    {
        /* Check if the parent device has anything at the same level */
        bSuccess = m_Devices->GetSiblingDevice(Device, &Device);
        if (bSuccess == FALSE) break;

        /* Lookup the info about this device */
        bSuccess = m_Devices->GetDevice(Device,
                                        DeviceName,
                                        DEVICE_NAME_LEN,
                                        &DeviceId,
                                        &ClassImage,
                                        &DeviceStatus,
                                        &ProblemNumber);
        if (bSuccess)
        {
            /* Check if this is a hidden device */
            if (DeviceStatus & DN_NO_SHOW_IN_DM)
            {
                if (m_ShowHidden == FALSE)
                    continue;
            }

            /* Check if the device has a problem */
            if (DeviceStatus & DN_HAS_PROBLEM)
            {
                OverlayImage = 1;
            }

            /* The disabled overlay takes precidence over the problem overlay */
            if (ProblemNumber == CM_PROB_HARDWARE_DISABLED)
            {
                OverlayImage = 2;
            }


            /* Add this device to the tree under its parent */
            hDevItem = InsertIntoTreeView(hParentTreeItem,
                                            DeviceName,
                                            (LPARAM)DeviceId,
                                            ClassImage,
                                            0);
            if (hDevItem)
            {
                /* Check if this child has any children itself */
                RecurseChildDevices(Device, hDevItem);
            }
        }
    }

    (void)TreeView_SortChildren(m_hTreeView,
                                hParentTreeItem,
                                0);
}