c - Enumerating interfaces in device info set obtained for a specific PnP enumerator -
i'm trying device interfaces data via setupdienumdeviceinterfaces()
devices correspond specific pnp enumerator. consider following example (for interface index 0 only):
#include <stdio.h> #include <windows.h> #include <setupapi.h> static int get_interface(hdevinfo); int main() { hdevinfo devinfoset = setupdigetclassdevsa(null, "usbstor", null, digcf_allclasses | digcf_present); if (devinfoset == invalid_handle_value) { fprintf(stderr, "setupdigetclassdevsa: error %lu\n", getlasterror()); return 1; } int ret = get_interface(devinfoset); setupdidestroydeviceinfolist(devinfoset); return ret; } int get_interface(hdevinfo devinfoset) { sp_device_interface_data deviface = { sizeof(sp_device_interface_data) }; if (!setupdienumdeviceinterfaces(devinfoset, null, &guid_devinterface_disk, 0, &deviface)) { fprintf(stderr, "setupdienumdeviceinterfaces: error %lu\n", getlasterror()); return 1; } /* ... */ }
(a more complete version of example available here.)
upon running that, setupdienumdeviceinterfaces()
fails getlasterror()
returning error 259 (error_no_more_items
), if there weren't interfaces device info set begin with. seems behavior device info sets obtained device setup classes rather device interface classes.
however when add digcf_deviceinterface
flag last argument of setupdigetclassdevsa()
call, set obtained interface classes, latter fails error 13 (error_invalid_data
). same error ensues in case of device setup classes when pnp enumerator specified not registered within system. indeed, when replace enumerator argument null
, interface obtained successfully. according msdn, specifying digcf_deviceinterface
flag allows use of device instance id in place of enumerator argument, occurs me aforementioned device instance ids , null
options setupdigetclassdevs()
call's enumerator argument, when has digcf_deviceinterface
flag present, actual enumerators being out of option in case.
could please explain me, going on here? i'm not familiar setupapi semantics can't tell limitations getting device info set device setup classes have imposed, in contrast device interface classes. also, there version-specific behavior in here? code above tested on windows 7 x64 system, being compiled 32-bit executable. need know if particular solution proposed work on ol' windows xp well.
p.s. not duplicate of getting device path createfile while enumerating devices setupdienumdeviceinfo, despite similar underlying purpose. ;)
Comments
Post a Comment