enumerate all PNPs

Share your advanced PureBasic knowledge/code with the community.
User avatar
bingo
Enthusiast
Enthusiast
Posts: 210
Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:

enumerate all PNPs

Post by bingo »

Code updated For 5.20+

:lol:

Code: Select all

#DIGCF_PRESENT                     =   2 
#DIGCF_ALLCLASSES                  =   4 

hDeviceInfoSet = SetupDiGetClassDevs_(0,0,0,#DIGCF_PRESENT|#DIGCF_ALLCLASSES)

Structure SP_DEVINFO_DATA 
  cbSize.l 
  ClassGuid.GUID 
  DevInst.l 
  Reserved.l 
EndStructure 

DeviceInfoData.SP_DEVINFO_DATA 

DeviceInfoData\cbSize=SizeOf(DeviceInfoData) 

i=0
OpenLibrary(1,"cfgmgr32.dll") 
*F1 = GetFunction(1, "CM_Get_Device_IDA") 
While SetupDiEnumDeviceInfo_(hDeviceInfoSet,i,@DeviceInfoData)
i+1
pnplen = 255
pnp.s = Space(pnplen)
CallFunctionFast(*F1,DeviceInfoData\DevInst,@pnp,pnplen,0) 
Debug pnp
Wend
SetupDiDestroyDeviceInfoList_(hDeviceInfoSet)
CloseLibrary(1)
["1:0>1"]