How to Get USB attached Devices ' name using setupDi calls ?
-
When already using Setup API functions, call one that accepts a pointer to a
SP_DEVINFO_DATA
structure (e.g.SetupDiGetDeviceInterfaceDetail()
orSetupDiEnumDeviceInfo()
). Then callSetupDiGetDeviceRegistryProperty()
passing the structure to get theSPDRP_FRIENDLYNAME
property which contains the name as shown by Windows. If that fails, you can fallback to get theSPDRP_DEVICEDESC
property.Thanks For your Reply. I tried Friendlyname,it is returning NULL. then I tried DeviceDesc , it is returning "USB PRINTING SUPPORT " for each USB connected Printer. I tried by passing SPDRP_MFG even, it is returning Microsoft. Any other way to get name so, I can differentiate. Thanks & Regards Y
-
Thanks For your Reply. I tried Friendlyname,it is returning NULL. then I tried DeviceDesc , it is returning "USB PRINTING SUPPORT " for each USB connected Printer. I tried by passing SPDRP_MFG even, it is returning Microsoft. Any other way to get name so, I can differentiate. Thanks & Regards Y
It seems that you have enumerated the generic Microsoft USB printing support devices. You should look up the specific printers instead which usually provide a friendly name. If that did not provide the device path, you must perform two enumerations and compare common data (e.g. the hardware ID).
-
It seems that you have enumerated the generic Microsoft USB printing support devices. You should look up the specific printers instead which usually provide a friendly name. If that did not provide the device path, you must perform two enumerations and compare common data (e.g. the hardware ID).
Ahh, But I used Class ID #define CLSID_STR_WEIUSB (L"{28D78FAD-5A12-11D1-AE5B-0000F803A8C2}") to get List of USB Printer Devices. I tried one another too #define CLSID_STR_WEIUSB1 (L"{A5DCBF10-6530-11D2-901F-00C04FB951ED}") but this one was not showing some of printers while Enumerating. Give me some Idea.How can I look up specific printers only and their Friendlynames? Regards Y
-
Ahh, But I used Class ID #define CLSID_STR_WEIUSB (L"{28D78FAD-5A12-11D1-AE5B-0000F803A8C2}") to get List of USB Printer Devices. I tried one another too #define CLSID_STR_WEIUSB1 (L"{A5DCBF10-6530-11D2-901F-00C04FB951ED}") but this one was not showing some of printers while Enumerating. Give me some Idea.How can I look up specific printers only and their Friendlynames? Regards Y
Those IDs seem to belong to specific devices. It is often difficult to get the proper GUID. See System-Defined Device Setup Classes[^] for a list of GUIDs. You may try the Printers GUID from that list and if that does not find all try also the USB Devices GUID.
-
Those IDs seem to belong to specific devices. It is often difficult to get the proper GUID. See System-Defined Device Setup Classes[^] for a list of GUIDs. You may try the Printers GUID from that list and if that does not find all try also the USB Devices GUID.
-
I tried system Defined specific printer GUID and USB GUID too. Printer = {4d36e979-e325-11ce-bfc1-08002be10318} USB = {88BAE032-5A81-49f0-BC3D-A4FF138216D6} but in this case it is not providing any device while enumerating. Y
What are the other parameters passed to
SetupDIGetClassDevs()
? Maybe this link may also help you: http://stackoverflow.com/questions/10651949/figuring-which-printer-name-corresponds-to-which-device-id[^]. For specific printers you may also get the GUID from the INF file of the printer. But this may again provide no friendly name. -
hello Friends I am accessing USB Devices through SetupDiCalls. I am able to get USb printers'Device Path to communicate with them and its working fine. I want to know that How can I access their name also using SetuDiCalls so that I can differentiate between USB Printer Devices to with whom I have to communicate. I tried EnumPrinters to get Printers name but that doesn't provide device Path for which we needed to pass to createFile fn for communication with USB Printer. And Nothing else I found common between ENumprinter returns or setupDicalls so that I will access from their. Any Ideas ? Thanks & Regards Y
-
What are the other parameters passed to
SetupDIGetClassDevs()
? Maybe this link may also help you: http://stackoverflow.com/questions/10651949/figuring-which-printer-name-corresponds-to-which-device-id[^]. For specific printers you may also get the GUID from the INF file of the printer. But this may again provide no friendly name.I am using it like this
#define CLSID_STR_WEIUSB1 (L"{A5DCBF10-6530-11D2-901F-00C04FB951ED}")
GUID DevClass; // CLSID holder for the WEIUSB device class
CLSIDFromString(CLSID_STR_WEIUSB1, &DevClass);
SetupDiGetClassDevs(
&DevClass, // Only get WEIUSB devices
NULL, // Not specific to any bus
NULL, // Not associated with any window
DIGCF_DEVICEINTERFACE + DIGCF_PRESENT -
I am using it like this
#define CLSID_STR_WEIUSB1 (L"{A5DCBF10-6530-11D2-901F-00C04FB951ED}")
GUID DevClass; // CLSID holder for the WEIUSB device class
CLSIDFromString(CLSID_STR_WEIUSB1, &DevClass);
SetupDiGetClassDevs(
&DevClass, // Only get WEIUSB devices
NULL, // Not specific to any bus
NULL, // Not associated with any window
DIGCF_DEVICEINTERFACE + DIGCF_PRESENTI found another fn but I don't know it is useful or am I using it Wrong ? SetupDiOpenDeviceInterfaceRegKey
Passing SP_DEVICE_INTERFACE_DATA DevNode which we Get from SetupDiEnumDeviceInterfaces
HKEY hKey = SetupDiOpenDeviceInterfaceRegKey(hDevInfoSet,&DevNode,0,KEY_READ);
RegQueryValueEx(hKey,_T("Port"),NULL,NULL,(LPBYTE)buf,&dwBufSize);But When I tried buf is coming NULL always. Is it Right way to find from resitry? Regards Y
-
I am using it like this
#define CLSID_STR_WEIUSB1 (L"{A5DCBF10-6530-11D2-901F-00C04FB951ED}")
GUID DevClass; // CLSID holder for the WEIUSB device class
CLSIDFromString(CLSID_STR_WEIUSB1, &DevClass);
SetupDiGetClassDevs(
&DevClass, // Only get WEIUSB devices
NULL, // Not specific to any bus
NULL, // Not associated with any window
DIGCF_DEVICEINTERFACE + DIGCF_PRESENTThe GUID you are using is GUID_DEVINTERFACE_USB_DEVICE[^]. You should use this or a similar name when not using the predefined one. Using this GUID, you are enumerating the raw USB devices which may not provide the user friendly name. You also may have a look at the USBView sample application[^]. To check if there is any entry for your printers with the user friendly name, enumerate all devices (GUID NULL,
DIGCF_ALLCLASSES
) and compare the hardware ID or other properties with those found enumerating the raw devices.