Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/Win/DirectShow/List devices
Required plugins for this example: MBS Win Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/DirectShow/List devices
This example is the version from Sun, 17th Mar 2012.
Project "List devices.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() if TargetWin32 then // ok else MsgBox "This example requires Windows." quit end if End EventHandler
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub ExpandRow(row As Integer) dim e as DirectShowEnumMonikerMBS = me.RowTag(row) dim dev as DirectShowMonikerMBS = e.NextObject while dev<>nil Add dev, "" dev = e.NextObject wend End EventHandler
End Control
EventHandler Sub Open() list DirectShowEnumMonikerMBS.CLSID_AudioCompressorCategory, "Audio Compressor" list DirectShowEnumMonikerMBS.CLSID_AudioInputDeviceCategory, "Audio Input" list DirectShowEnumMonikerMBS.CLSID_AudioRendererCategory, "Audio Renderer" list DirectShowEnumMonikerMBS.CLSID_DeviceControlCategory, "Device Control" list DirectShowEnumMonikerMBS.CLSID_DVDHWDecodersCategory, "DVD Hardware Decoder" list DirectShowEnumMonikerMBS.CLSID_LegacyAmFilterCategory, "Legacy AmFilter" list DirectShowEnumMonikerMBS.CLSID_MidiRendererCategory, "Midi Renderer" list DirectShowEnumMonikerMBS.CLSID_TransmitCategory, "Transcoder" list DirectShowEnumMonikerMBS.CLSID_VideoCompressorCategory, "Video Compressor" list DirectShowEnumMonikerMBS.CLSID_VideoInputDeviceCategory, "Video Input" End EventHandler
Sub Add(dev As DirectShowMonikerMBS, type as string) // check subobjects dim e as DirectShowEnumMonikerMBS = dev.EnumMonikers(true) // Microsoft calls it Displayname, but it looks more like some UniqueID dim DisplayName as string = dev.DisplayName if e<>Nil then // there could be components of a composite moniker. List.AddFolder DisplayName else List.AddRow DisplayName end if System.DebugLog str(dev.Lasterror)+" "+str(dev.LasterrorMessage) dim p as DirectShowPropertyBagMBS = dev.Properties if p<>nil then // we show some properties List.Cell(List.LastIndex,2) = p.FriendlyName if p.Lasterror = &h80070002 or p.Lasterror = &h80070490 then // property not found List.Cell(List.LastIndex,2) = "-" elseif p.Lasterror <>0 then List.Cell(List.LastIndex,2) = "Error "+hex(p.Lasterror)+": "+p.LasterrorMessage end if List.Cell(List.LastIndex,3) = p.Description if p.Lasterror = &h80070002 or p.Lasterror = &h80070490 then // property not found List.Cell(List.LastIndex,3) = "-" elseif p.Lasterror <>0 then List.Cell(List.LastIndex,3) = "Error "+hex(p.Lasterror)+": "+p.LasterrorMessage end if List.Cell(List.LastIndex,4) = p.DevicePath if p.Lasterror = &h80070002 or p.Lasterror = &h80070490 then // property not found List.Cell(List.LastIndex,4) = "-" elseif p.Lasterror <>0 then List.Cell(List.LastIndex,4) = "Error "+hex(p.Lasterror)+": "+p.LasterrorMessage end if end if List.Cell(List.LastIndex,1) = type List.RowTag(List.LastIndex) = e // help tags make long text more visible when you move mouse over entry for i as integer = 0 to 4 List.CellHelpTag(list.lastIndex,i) = List.Cell(list.lastIndex,i) next End Sub
Sub List(type as DirectShowGUIDMBS, types as string) // Create an enumerator for the video capture devices dim devenum as new DirectShowEnumMonikerMBS(type) if devenum.Handle = 0 then Return end if dim dev as DirectShowMonikerMBS = devenum.NextObject while dev<>nil Add dev, types dev = devenum.NextObject wend End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "Edit"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Win Plugin.

MBS Xojo tutorial videos