@@ -9,13 +9,13 @@ use windows_sys::{
9
9
Win32 :: Devices :: DeviceAndDriverInstallation :: {
10
10
SetupDiDestroyDeviceInfoList , SetupDiEnumDeviceInfo , SetupDiGetClassDevsW ,
11
11
SetupDiGetDeviceInstanceIdW , SetupDiGetDeviceRegistryPropertyW , DIGCF_ALLCLASSES ,
12
- DIGCF_PRESENT , SPDRP_CLASS , SPDRP_DEVICEDESC , SPDRP_HARDWAREID , SP_DEVINFO_DATA ,
12
+ DIGCF_PRESENT , SPDRP_CLASS , SPDRP_DEVICEDESC , SPDRP_FRIENDLYNAME , SPDRP_HARDWAREID ,
13
+ SPDRP_MFG , SP_DEVINFO_DATA ,
13
14
} ,
14
15
} ;
15
16
16
17
pub fn enumerate_platform ( vid : Option < u16 > , pid : Option < u16 > ) -> Vec < UsbDevice > {
17
18
let mut output: Vec < UsbDevice > = Vec :: new ( ) ;
18
- // let usb: Vec<u16> = OsStr::new("USB\0").encode_wide().collect();
19
19
let usb = w ! ( "USB\0 " ) ;
20
20
let dev_info =
21
21
unsafe { SetupDiGetClassDevsW ( null ( ) , usb, -1 , DIGCF_ALLCLASSES | DIGCF_PRESENT ) } ;
@@ -77,6 +77,42 @@ pub fn enumerate_platform(vid: Option<u16>, pid: Option<u16>) -> Vec<UsbDevice>
77
77
class = Some ( string_from_buf_u8 ( buf) ) ;
78
78
}
79
79
80
+ // manufactor
81
+ buf = vec ! [ 0 ; 1000 ] ;
82
+ let mut manufacturer = None ;
83
+ if unsafe {
84
+ SetupDiGetDeviceRegistryPropertyW (
85
+ dev_info,
86
+ & mut dev_info_data,
87
+ SPDRP_MFG ,
88
+ null_mut ( ) ,
89
+ buf. as_mut_ptr ( ) ,
90
+ buf. len ( ) as u32 ,
91
+ null_mut ( ) ,
92
+ )
93
+ } > 0
94
+ {
95
+ manufacturer = Some ( string_from_buf_u8 ( buf) ) ;
96
+ }
97
+
98
+ // friendly name
99
+ buf = vec ! [ 0 ; 1000 ] ;
100
+ let mut friendly_name = None ;
101
+ if unsafe {
102
+ SetupDiGetDeviceRegistryPropertyW (
103
+ dev_info,
104
+ & mut dev_info_data,
105
+ SPDRP_FRIENDLYNAME ,
106
+ null_mut ( ) ,
107
+ buf. as_mut_ptr ( ) ,
108
+ buf. len ( ) as u32 ,
109
+ null_mut ( ) ,
110
+ )
111
+ } > 0
112
+ {
113
+ friendly_name = Some ( string_from_buf_u8 ( buf) ) ;
114
+ }
115
+
80
116
buf = vec ! [ 0 ; 1000 ] ;
81
117
82
118
if unsafe {
@@ -111,6 +147,8 @@ pub fn enumerate_platform(vid: Option<u16>, pid: Option<u16>) -> Vec<UsbDevice>
111
147
id,
112
148
vendor_id,
113
149
product_id,
150
+ friendly_name,
151
+ manufacturer,
114
152
description : Some ( description) ,
115
153
serial_number,
116
154
base_class : class. map ( |cls| cls. into ( ) ) ,
0 commit comments