Platforms to show: All Mac Windows Linux Cross-Platform

/MacCF/IORegistry


Required plugins for this example: MBS MacCF Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/IORegistry

This example is the version from Sun, 17th Mar 2012.

Project "IORegistry.xojo_binary_project"
Class Window1 Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub Change() update End EventHandler
EventHandler Sub ExpandRow(row As Integer) dim i as IORegistryNodeMBS = List.RowTag(row) dim nodes() as IORegistryNodeMBS = i.Children for each node as IORegistryNodeMBS in nodes addnode node next End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control oname Inherits Label
ControlInstance oname Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control oclass Inherits Label
ControlInstance oclass Inherits Label
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control opath Inherits Label
ControlInstance opath Inherits Label
End Control
Control dataList Inherits ListBox
ControlInstance dataList Inherits ListBox
End Control
Control PopupTree Inherits PopupMenu
ControlInstance PopupTree Inherits PopupMenu
EventHandler Sub Change() start End EventHandler
End Control
Control FindField Inherits TextField
ControlInstance FindField Inherits TextField
End Control
Control FindButton Inherits PushButton
ControlInstance FindButton Inherits PushButton
EventHandler Sub Action() dim foundNodes() as IORegistryNodeMBS dim s as string = FindField.Text.Trim if s <> "" then FindInIORegistry s, root, foundNodes end // now put the found nodes into the list as root items list.deleteAllRows for each node as IORegistryNodeMBS in foundNodes addnode node next PopupTree.ListIndex = PopupTree.ListCount-1 End EventHandler
End Control
EventHandler Sub Open() if IORegistryMBS.Present then start else msgBox "No IO Registry. Please run on Mac OS X." end if End EventHandler
Sub FindInIORegistry(textToFind as String, insideNode as IORegistryNodeMBS, foundOut() as IORegistryNodeMBS) dim children() as IORegistryNodeMBS = insideNode.Children for each node as IORegistryNodeMBS in children if node.IOClass.InStr(textToFind) > 0 then foundOut.Append node elseif node.Name.InStr(textToFind) > 0 then foundOut.Append node else // check the values of the node dim dic as Dictionary = node.Properties for each key as Variant in dic.keys dim value as Variant = dic.Value(key) dim keyname as string = VariantText(key) dim valname as string = VariantText(value) if valName.InStr(textToFind) > 0 then foundOut.Append node exit for key end if keyname.InStr(textToFind) > 0 then foundOut.Append node exit for key end if next end // always check the sub nodes, too FindInIORegistry textToFind, node, foundOut next End Sub
Function VariantText(v as Variant) As string if v.IsArray then Return "<Array>" if v isa Dictionary then Return "<Dictionary>" Return v exception // ignore all End Function
Sub addnode(i as ioregistrynodeMBS) if i<>nil then if i.ChildCount <= 0 then list.addrow i.name else list.addfolder i.name end if list.cell(list.lastIndex,1)=str(i.ChildCount) list.RowTag(List.LastIndex) = i else MsgBox "addnode: nil!" end if End Sub
Sub showdata(node as ioregistrynodeMBS) dim dic as Dictionary = node.Properties for each key as Variant in dic.keys dim value as Variant = dic.Value(key) dataList.AddRow VariantText(key) dataList.cell(dataList.LastIndex,1) = VariantText(value) next End Sub
Sub start() list.deleteAllRows select case popupTree.listindex case 0 root = IORegistryMBS.ServiceRoot case 1 root = IORegistryMBS.DeviceRoot case 2 root = IORegistryMBS.PowerRoot case 3 root = IORegistryMBS.AudioRoot case 4 root = IORegistryMBS.FirewireRoot case 5 root = IORegistryMBS.USBRoot else FindButton.Push Return end select addnode root End Sub
Sub update() dim n as integer dataList.deleteAllRows dim l as integer = list.listindex if l>=0 then dim i as IORegistryNodeMBS = List.RowTag(l) oname.text=i.name oclass.text=i.IOClass opath.text=i.path showdata i return end if oname.text="" oclass.text="" opath.text="" End Sub
Property root As IORegistryNodeMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

See also:

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


The biggest plugin in space...