le code n'est pas très propres j'ai essayé de faire au plus simple.
Code : Tout sélectionner
#DIGCF_DEVICEINTERFACE = 16 ;10 en hexa
Structure SP_DEVICE_INTERFACE_DATA
cbSize.l
InterfaceClassGuid.GUID
Flags.l
Reserved.l
EndStructure
Structure SP_DEVICE_INTERFACE_DETAIL_DATA_A
cbSize.w;
DevicePath.s;
EndStructure
Prototype SDEDI(a,b,c,d,e)
Prototype SDGDID(DeviceInfoSet.l, DeviceInterfaceData.l, *DeviceInterfaceDetailData, DeviceInterfaceDetailDataSize.l, *RequiredSize, *DeviceInfoData)
Prototype SDDDIL(DeviceInfoSet.l)
Prototype ProtoHidD_GHG(*GUID.GUID)
;=========================================================================================
;chargement de la lib Setupapi
;=========================================================================================
setupapi = OpenLibrary(#PB_Any,"Setupapi.dll")
SetupDiEnumDeviceInterfaces.SDEDI = GetFunction(setupapi,"SetupDiEnumDeviceInterfaces")
SetupDiGetDeviceInterfaceDetail.SDGDID = GetFunction(setupapi,"SetupDiGetDeviceInterfaceDetailW")
SetupDiDestroyDeviceInfoList.SDDDIL = GetFunction(setupapi,"SetupDiDestroyDeviceInfoList")
;=========================================================================================
;chargement de la lib Human Interface Device
;=========================================================================================
hid = OpenLibrary(#PB_Any, "hid.dll")
HidD_GetHidGuid.ProtoHidD_GHG = GetFunction(hid, "HidD_GetHidGuid")
;=========================================================================================
;-start
;=========================================================================================
*guid.GUID = AllocateMemory(SizeOf(GUID))
HidD_GetHidGuid(*guid)
hIntDevInfo = SetupDiGetClassDevs_(*guid, #Null, #Null, #DIGCF_DEVICEINTERFACE)
*didata.SP_DEVICE_INTERFACE_DATA = AllocateMemory(SizeOf(SP_DEVICE_INTERFACE_DATA))
*didata\cbSize = SizeOf(SP_DEVICE_INTERFACE_DATA)
didetail.SP_DEVICE_INTERFACE_DETAIL_DATA_A
Size.l
index = 0
While SetupDiEnumDeviceInterfaces(hIntDevInfo, #Null, *guid, index, *didata)
Debug "found"
Size = 0
Debug SetupDiGetDeviceInterfaceDetail(hIntDevInfo, *didata, #Null, 0, @Size, #Null);
Debug GetLastError_()
index + 1
Wend
le debugeur me donne :
found
0
122
found
0
122
la fonction SetupDiGetDeviceInterfaceDetail renvoie vrai(#true) en cas de réussite donc il y a un problème comme le confirme le GetLastError qui renvoie l'erreur 122 qui correspond a ERROR_INSUFFICIENT_BUFFER.
cependant j'ai passé tout l'après midi a trouver le pourquoi du comment sans succès, si quelqu'un a une idée ......