Hi.
Does anyone know how to read the VID and PID of webcam connected to a computer via USB?
How to read the VID PID of the USB webcam
Re: How to read the VID PID of the USB webcam
lsusb
But I can not see what kind of OS you are running.
But I can not see what kind of OS you are running.
Re: How to read the VID PID of the USB webcam
Perhaps getting the hardware information might shine some light on what you need.
From:https://www.voti.nl/docs/usb-pid.html
http://www.purebasic.fr/english/viewtop ... =5&t=65328
Results I obtained:
From:https://www.voti.nl/docs/usb-pid.html
search for: GetHardwareList_Func.pbi By Thunder93"The PC uses the VID/PID combination to find the drivers (if any) that are to be used for the USB device."
http://www.purebasic.fr/english/viewtop ... =5&t=65328
Results I obtained:
Hopefully you get some information that you need.-----------------------
Item: 325
Device Name: Logitech Webcam 905
Class: Image
Class Description: Imaging devices
Class GUID: {4BDD1D6-810F-11D0-BEC7-08002BE2092F}
Class Image Index: 63
CM_Status: 25190410
CM_Problem: 0
Device Status flags...:
DN_DRIVER_LOADED
DN_STARTED
DN_DISABLEABLE
DN_REMOVABLE
DN_NT_ENUMERATOR
DN_NT_DRIVER
-----------------------------
- It was too lonely at the top.
System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Re: How to read the VID PID of the USB webcam
Thanks, guys!
infratec, my OS is Windows XP and 7. lsusb works fine and this is exactly what I need. But I would like to get the same result on PureBasic.
blueb, i can't get setupapi_h.pbi and cfg_h.pbi from http://www.purebasic.fr/english/viewtop ... =5&t=65230 :
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable"
infratec, my OS is Windows XP and 7. lsusb works fine and this is exactly what I need. But I would like to get the same result on PureBasic.
blueb, i can't get setupapi_h.pbi and cfg_h.pbi from http://www.purebasic.fr/english/viewtop ... =5&t=65230 :
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable"
Re: How to read the VID PID of the USB webcam
The answer is
Many thanks to Thunder93 for the start point: Device Manager!
P.S. Windows XP 32 bit, my result:
Code: Select all
#MAX_CLASS_NAME_LEN = 32
#MAX_DEV_NAME_LEN = 512
#SPDRP_HARDWAREID = 1
#SPDRP_CLASS = 7
Structure SP_DEVINFO_DATA Align #PB_Structure_AlignC
cbSize.l
ClassGuid.GUID
DevInst.l
*Reserved
EndStructure
Global hDevInfo.l, DeviceInfoData.SP_DEVINFO_DATA, setupapi.l, Ncam.l = 0, funcExt.s, MemberIndex.l = 0, CM_Status.l = 0, CM_Problem.l = 0
Global DevName.s = Space(#MAX_DEV_NAME_LEN), DevClass.s = Space(#MAX_CLASS_NAME_LEN)
CompilerIf #PB_Compiler_Unicode
funcExt = "W"
CompilerElse
funcExt = "A"
CompilerEndIf
Prototype.l CM_Get_DevNode_Status(pulStatus.l,pulProblemNumber.l,dnDevInst,ulFlags.l)
Prototype.l SetupDiGetClassDevs(*ClassGuid,Enumerator,hwndParent,Flags.l)
Prototype.l SetupDiEnumDeviceInfo(DeviceInfoSet,MemberIndex.l,DeviceInfoData)
Prototype.l SetupDiGetDeviceRegistryProperty(DeviceInfoSet,DeviceInfoData,Property.l,PropertyRegDataType.l,PropertyBuffer,PropertyBufferSize.l,RequiredSize.l)
setupapi = OpenLibrary(#PB_Any, "setupapi.dll")
If setupapi
CM_Get_DevNode_Status.CM_Get_DevNode_Status = GetFunction(setupapi, "CM_Get_DevNode_Status")
SetupDiGetClassDevs.SetupDiGetClassDevs = GetFunction(setupapi, "SetupDiGetClassDevs"+funcExt)
SetupDiEnumDeviceInfo.SetupDiEnumDeviceInfo = GetFunction(setupapi, "SetupDiEnumDeviceInfo")
SetupDiGetDeviceRegistryProperty.SetupDiGetDeviceRegistryProperty = GetFunction(setupapi, "SetupDiGetDeviceRegistryProperty"+funcExt)
Else
MessageRequester("Error", "Can't open library setupapi.dll")
End
EndIf
*pGUID = ?GUID_USB_DEVICE
hDevInfo = SetupDiGetClassDevs(*pGUID, #Null, #Null, #DIGCF_PRESENT | #DIGCF_ALLCLASSES)
If hDevInfo = #INVALID_HANDLE_VALUE
MessageRequester("Error", "Inavlid handle value")
End
EndIf
DeviceInfoData\cbSize = SizeOf(SP_DEVINFO_DATA)
While SetupDiEnumDeviceInfo(hDevInfo, MemberIndex, @DeviceInfoData)
CM_Get_DevNode_Status(@CM_Status, @CM_Problem, DeviceInfoData\DevInst, 0)
SetupDiGetDeviceRegistryProperty(hDevInfo, @DeviceInfoData, #SPDRP_CLASS, #Null, @DevClass, #MAX_CLASS_NAME_LEN, #Null)
; only connected webcams (ImageClass USB devices)
If CM_Status <> 0 And DevClass = "Image"
SetupDiGetDeviceRegistryProperty(hDevInfo, @DeviceInfoData, #SPDRP_HARDWAREID, #Null, @DevName, #MAX_DEV_NAME_LEN, #Null)
Ncam + 1
Debug "Class: "+DevClass+", CM_Status: "+ Str(CM_Status)+", CM_Problem: "+ Str(CM_Problem)
Debug "Device Name: "+DevName +#CRLF$
EndIf
MemberIndex + 1 : CM_Status = 0 : CM_Problem = 0
Wend
Debug (Str(Ncam) + " webcam(s) found")
DataSection
GUID_USB_DEVICE:
Data.l $6BDD1FC6
Data.w $810F, $11D0
Data.b $BE, $C7, $08, $00, $2B, $E2, $09, $2F
EndDataSection
P.S. Windows XP 32 bit, my result:
Code: Select all
Class: Image, CM_Status: 25190410, CM_Problem: 0
Device Name: USB\Vid_05a3&Pid_9310&Rev_0000&MI_00
Class: Image, CM_Status: 25190410, CM_Problem: 0
Device Name: USB\Vid_0c45&Pid_62b3&Rev_0100&MI_00
2 webcam(s) found