IoGetConfigurationInformation 接口使用--增加系统设备数量

来源:互联网 发布:mac激活时间查询 编辑:程序博客网 时间:2024/06/09 17:45

           在编写USB转虚拟串口驱动程序过程中,PC上每插入一个USB设备,我们就需要生成一个串口设备。这样我们就需要增加系统的串口设备数量,这时就需要用到 IoGetConfigurationInformation 接口了。

           这个接口使用的频率相对不高,因此整理下,方便后续查看以及消化理解。

           接口定义如下:   

PCONFIGURATION_INFORMATION IoGetConfigurationInformation(void);

          调用返回的数据结构如下:

typedef struct _CONFIGURATION_INFORMATION {    //    // This field indicates the total number of disks in the system. This    // number should be used by the driver to determine the names of new    // disks. This field should be updated by the driver as it finds new    // disks.    //    ULONG DiskCount;                // Count of hard disks thus far    ULONG FloppyCount;              // Count of floppy disks thus far    ULONG CdRomCount;               // Count of CD-ROM drives thus far    ULONG TapeCount;                // Count of tape drives thus far    ULONG ScsiPortCount;            // Count of SCSI port adapters thus far    ULONG SerialCount;              // Count of serial devices thus far    ULONG ParallelCount;            // Count of parallel devices thus far    //    // These next two fields indicate ownership of the two I/O address    // spaces that are used by WD1003-compatible disk controllers.    //    BOOLEAN AtDiskPrimaryAddressClaimed;    // 0x1F0 - 0x1FF    BOOLEAN AtDiskSecondaryAddressClaimed;  // 0x170 - 0x17F    //    // Indicates the structure version, as anything value beyond this will have been added.    // Use the structure size as the version.    //    ULONG Version;    //    // Indicates the total number of medium changer devices in the system.    // This field will be updated by the drivers as it determines that    // new devices have been found and will be supported.    //    ULONG MediumChangerCount;} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;

         通过返回的结构体我们可以知道系统中原本的设备的数量,同时我们可以增加或者减少设备数量,不仅仅是串口设备,可以是磁盘,并口等其它设备。

      

0 0
原创粉丝点击