private DLDevice FindDeviceInDLThree(WindowsDevice dockRepresentation)
        {
            DLDevice result = null;

            Stack <DLDevice> stack = new Stack <DLDevice>();
            DLDevice         node  = m_PC;

            while (node != null)
            {
                if (node.WindowsDevice == dockRepresentation)
                {
                    result = node;
                    break;
                }

                foreach (var e in node.Children)
                {
                    stack.Push(e);
                }

                node = null;
                if (stack.Count > 0)
                {
                    node = stack.Pop();
                }
            }

            return(result);
        }
        private WindowsDevice FindDeviceWhichRepresentingDock(WindowsDevice displayAdapter)
        {
            WindowsDevice dock = null;

            if (displayAdapter.Parent != null)
            {
                if (displayAdapter.Parent.Parent != null)
                {
                    dock = displayAdapter.Parent.Parent;
                }
            }

            return(dock);
        }
        public List <WindowsDevice> EnumerateDevices()
        {
            List <WindowsDevice> devices = new List <WindowsDevice>();

            uint result = 0;

            UInt32 size   = 0;                                                                          //size iz number of characters
            string filter = "";

            result = ConfigManagerAPI.CM_Get_Device_ID_List_SizeW(ref size, ref filter, 0);
            if (result == 0)
            {
                IntPtr buffer = Marshal.AllocHGlobal((int)size * 2);                                    //width of wchar is 2
                UInt32 flags  = 256;

                result = ConfigManagerAPI.CM_Get_Device_ID_ListW(ref filter, buffer, size, flags);
                if (result == 0)
                {
                    List <Tuple <string, int> > devicesList = ParseBuffer(buffer, size);

                    foreach (var device in devicesList)
                    {
                        UInt32 deviceInstance = 0;
                        IntPtr ptrToDeviceId  = IntPtr.Add(buffer, device.Item2);
                        result = ConfigManagerAPI.CM_Locate_DevNodeW(ref deviceInstance, ptrToDeviceId, 0);

                        if (result == 0)
                        {
                            string        id            = device.Item1;
                            string        deviceClass   = GetPropertString(deviceInstance, new ConfigManagerAPI.DeviceInfo(new Guid(DEV_INFO_DEVICE_CLASS_GUID), DEV_INFO_DEVICE_CLASS_PID));
                            string        parent        = GetPropertString(deviceInstance, new ConfigManagerAPI.DeviceInfo(new Guid(DEV_INFO_PARENT_ID_GUID), DEV_INFO_PARENT_ID_PID));
                            string        driverVersion = GetPropertString(deviceInstance, new ConfigManagerAPI.DeviceInfo(new Guid(DEV_INFO_DRIVER_VERSION_GUID), DEV_INFO_DRIVER_VERSION_PID));
                            List <string> children      = GetPropertStringList(deviceInstance, new ConfigManagerAPI.DeviceInfo(new Guid(DEV_INFO_CHILDREN_ID_GUID), DEV_INFO_CHILDREN_ID_PID));

                            WindowsDevice windowsDevice = new WindowsDevice(id, id, deviceClass, children, parent, driverVersion);
                            devices.Add(windowsDevice);
                        }
                    }
                }

                Marshal.FreeHGlobal(buffer);
            }

            InitializeDeviceSiblings(devices);

            return(devices);
        }
        private bool IsInParentChildRelationship(WindowsDevice parent, WindowsDevice child)
        {
            bool result = false;

            if (parent != null && child != null)
            {
                WindowsDevice device = child;
                while (device.Parent != null && device != device.Parent)
                {
                    if (device.Parent == parent)
                    {
                        result = true;
                        break;
                    }

                    device = device.Parent;
                }
            }

            return(result);
        }
 public DLMonitor(string name, WindowsDevice wDevice) :
     base(name, wDevice)
 {
 }
 public DLDock(string name, WindowsDevice wDevice) :
     base(name, wDevice)
 {
 }
Example #7
0
 public DLDevice(string name, WindowsDevice windowDevice)
 {
     m_name         = name;
     m_windowDevice = windowDevice;
 }