Пример #1
0
        public Boolean SupportsInterface(Guid classGuid)
        {
            uint len;
            CR   ret = SetupApi.CM_Get_Device_Interface_List_Size(out len, ref classGuid, DeviceID, 0);

            CMException.Throw(ret, "CM_Get_Device_Interface_List_Size");
            return(len > 2);
        }
Пример #2
0
        public Boolean GetStatus(out UInt32 status, out UInt32 problem)
        {
            CR ret = SetupApi.CM_Get_DevNode_Status(out status, out problem, DevInst, 0);

            if (ret == CR.NO_SUCH_DEVNODE)
            {
                return(false);
            }
            CMException.Throw(ret, "CM_Get_DevNode_Status");
            return(true);
        }
Пример #3
0
        public DeviceNode GetParent()
        {
            UInt32 node;
            CR     ret = SetupApi.CM_Get_Parent(out node, DevInst, 0);

            if (ret == CR.NO_SUCH_DEVNODE)
            {
                return(null);
            }
            CMException.Throw(ret, "CM_Get_Parent");
            return(new DeviceNode(node));
        }
Пример #4
0
        public static DeviceNode GetDevice(String deviceID)
        {
            UInt32 node;
            CR     ret = SetupApi.CM_Locate_DevNode(out node, deviceID, 4);

            if (ret == CR.NO_SUCH_DEVNODE)
            {
                return(null);
            }
            CMException.Throw(ret, "CM_Locate_DevNode");
            return(new DeviceNode(node));
        }
Пример #5
0
        public String[] GetInterfaces(Guid classGuid)
        {
            uint len;
            CR   ret = SetupApi.CM_Get_Device_Interface_List_Size(out len, ref classGuid, DeviceID, 0);

            CMException.Throw(ret, "CM_Get_Device_Interface_List_Size");
            if (len <= 1)
            {
                return(null);
            }
            Byte[] buffer = new Byte[2 * len];
            ret = SetupApi.CM_Get_Device_Interface_List(ref classGuid, DeviceID, buffer, len, 0);
            CMException.Throw(ret, "CM_Get_Device_Interface_List");
            return(SetupApi.GetAsStringArray(buffer, 2 * (int)len));
        }
Пример #6
0
        public Byte[] GetProperty(CMRDP property)
        {
            uint proplength = 0;
            uint proptype;
            CR   ret = SetupApi.CM_Get_DevNode_Registry_Property(DevInst, property, out proptype, null, ref proplength, 0);

            if (ret == CR.NO_SUCH_VALUE || ret == CR.NO_SUCH_DEVNODE)
            {
                return(null);
            }
            if (ret != CR.BUFFER_SMALL)
            {
                CMException.Throw(ret, "CM_Get_DevNode_Registry_Property");
            }
            Byte[] propbuffer = new Byte[proplength];
            ret = SetupApi.CM_Get_DevNode_Registry_Property(DevInst, property, out proptype, propbuffer, ref proplength, 0);
            CMException.Throw(ret, "CM_Get_DevNode_Registry_Property");
            if (propbuffer.Length > proplength)
            {
                Array.Resize(ref propbuffer, (int)proplength);
            }
            return(propbuffer);
        }
Пример #7
0
        public IList <DeviceNode> GetChildren()
        {
            UInt32 child;
            CR     ret = SetupApi.CM_Get_Child(out child, DevInst, 0);

            if (ret == CR.NO_SUCH_DEVNODE)
            {
                return(null);
            }
            CMException.Throw(ret, "CM_Get_Child");
            List <DeviceNode> list = new List <DeviceNode>();

            while (true)
            {
                list.Add(new DeviceNode(child));
                ret = SetupApi.CM_Get_Sibling(out child, child, 0);
                if (ret == CR.NO_SUCH_DEVNODE)
                {
                    break;
                }
                CMException.Throw(ret, "CM_Get_Sibling");
            }
            return(list);
        }
Пример #8
0
        public void Reenumerate(UInt32 flags)
        {
            CR ret = SetupApi.CM_Reenumerate_DevNode(DevInst, flags);

            CMException.Throw(ret, "CM_Reenumerate_DevNode");
        }