;Autor: bingo

EnableExplicit

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

Define DeviceInfoData.SP_DEVINFO_DATA
Define EventID
Define hDeviceInfoSet
Define *F1
Define i
Define pnplen = 255
Define bufferlen = 1024
Define pnp.s = Space(bufferlen)

#DIGCF_PRESENT = 2
#DIGCF_ALLCLASSES = 4

If OpenWindow(0,0,0,500,400,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ListViewGadget(1,10,10,WindowWidth(0)-20,WindowHeight(0)-20,0)
  
  hDeviceInfoSet = SetupDiGetClassDevs_(0,0,0,#DIGCF_PRESENT|#DIGCF_ALLCLASSES)
  DeviceInfoData\cbSize=SizeOf(DeviceInfoData)
  
  If OpenLibrary(1,"cfgmgr32.dll")
    *F1 = GetFunction(1, "CM_Get_Device_IDA")
    Repeat
      If SetupDiEnumDeviceInfo_(hDeviceInfoSet,i,@DeviceInfoData) = 0
        Break
      EndIf
      
      i+1
      
      CallFunctionFast(*F1,DeviceInfoData\DevInst,@pnp,pnplen,0)
      AddGadgetItem(1,-1,pnp,0,0)
    ForEver
    
    CloseLibrary(1)
  EndIf
  
  SetupDiDestroyDeviceInfoList_(hDeviceInfoSet)
  
  Repeat
    EventID=WaitWindowEvent()
    If EventID = #PB_Event_CloseWindow
      End
    EndIf
  ForEver
EndIf