Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
#Include Once "dshow.inc"
Global CameraCount As Long, CameraList$
Function PBMain() As Long
GetCameraList
? "Cameras: " + Str$(CameraCount) + $CrLf + CameraList$
End Function
Sub GetCameraList 'stops enumeration on moniker which has the friendly name
Local pceltFetched As Dword, pwszDisplayName As WStringZ Ptr, varName As Variant
Local pSysDevEnum As ICreateDevEnum
Local pEnumCat As IEnumMoniker
Local pMoniker As IMoniker
Local pPropBag As IPropertyBag
Local pbc As IBindCTX
Reset CameraCount, CameraList$
pSysDevEnum = NewCom ClsId $CLSID_SystemDeviceEnum 'enumeration object
If pSysDevEnum.CreateClassEnumerator($CLSID_VideoInputDeviceCategory, pEnumCat, 0) = %S_False Then Exit Sub
While pEnumCat.next(1, pMoniker, pceltFetched) <> %S_False
Incr CameraCount
pMoniker.GetDisplayName(pbc, Nothing, pwszDisplayName) 'get complex camera name
pMoniker.BindToStorage(Nothing, Nothing, $IID_IPropertyBag, pPropBag) 'get info about Moniker
pPropBag.Read("FriendlyName", varName, Nothing) 'get friendly name
CameraList$ += Variant$$(varName) + $CrLf
Wend
End Sub
http://www.garybeene.com/sw/gbsnippets.htm