Platforms to show: All Mac Windows Linux Cross-Platform

/Win/WMI/WMI HDD Info


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/WMI/WMI HDD Info

This example is the version from Fri, 12th Aug 2021.

Project "WMI HDD Info.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
Sub Constructor() // required for Windows 8.1 or later Call WindowsWMIMBS.InitSecurity(False) End Sub
End Class
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control eCaption Inherits Label
ControlInstance eCaption Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control eDescription Inherits Label
ControlInstance eDescription Inherits Label
End Control
Control eDeviceID Inherits Label
ControlInstance eDeviceID Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control eInterfaceType Inherits Label
ControlInstance eInterfaceType Inherits Label
End Control
Control eManufacturer Inherits Label
ControlInstance eManufacturer Inherits Label
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Control eModel Inherits Label
ControlInstance eModel Inherits Label
End Control
Control eName Inherits Label
ControlInstance eName Inherits Label
End Control
Control StaticText7 Inherits Label
ControlInstance StaticText7 Inherits Label
End Control
Control eSize Inherits Label
ControlInstance eSize Inherits Label
End Control
Control StaticText8 Inherits Label
ControlInstance StaticText8 Inherits Label
End Control
Control StaticText9 Inherits Label
ControlInstance StaticText9 Inherits Label
End Control
Control eSystemName Inherits Label
ControlInstance eSystemName Inherits Label
End Control
Control eSerialNumber Inherits Label
ControlInstance eSerialNumber Inherits Label
End Control
Control StaticText10 Inherits Label
ControlInstance StaticText10 Inherits Label
End Control
Control eVSerialNumber Inherits Label
ControlInstance eVSerialNumber Inherits Label
End Control
Control StaticText11 Inherits Label
ControlInstance StaticText11 Inherits Label
End Control
Control eMSerialNumber Inherits Label
ControlInstance eMSerialNumber Inherits Label
End Control
Control StaticText12 Inherits Label
ControlInstance StaticText12 Inherits Label
End Control
EventHandler Sub Open() dim s as string eVSerialNumber.text="n/a" eSerialNumber.text="n/a" if TargetWin32 then w=new WindowsWMIMBS if w.ConnectServer("root\cimv2") then if w.query("WQL","Select * from Win32_DiskDrive") then if w.NextItem then // first only eCaption.text=w.GetProperty("Caption") eDescription.text=w.GetProperty("Description") eDeviceID.text=w.GetProperty("DeviceID") eInterfaceType.text=w.GetProperty("InterfaceType") eManufacturer.text=w.GetProperty("Manufacturer") eModel.text=w.GetProperty("Model") eName.text=w.GetProperty("Name") eSize.text=w.GetProperty("Size") eSystemName.text=w.GetProperty("SystemName") end if else MsgBox "query: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if else MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if w=new WindowsWMIMBS if w.ConnectServer("root\cimv2") then if w.query("WQL","Select * from Win32_PhysicalMedia") then while w.NextItem // find the first serial number known s=w.GetProperty("SerialNumber") if s<>"" then eSerialNumber.text=s exit // got one end if wend else MsgBox "query: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if else MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if w=new WindowsWMIMBS if w.ConnectServer("root\cimv2") then if w.query("WQL","Select * from Win32_LogicalDisk") then while w.NextItem // find the first volume serial number known s=w.GetProperty("VolumeSerialNumber") if s<>"" then eVSerialNumber.text=s exit end if wend else MsgBox "query: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if else MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if w=new WindowsWMIMBS if w.ConnectServer("root\cimv2") then if w.query("WQL","Select * from Win32_SystemEnclosure") then while w.NextItem // find the system serial number s=w.GetProperty("SerialNumber") if s<>"" then eMSerialNumber.text=s exit end if wend else MsgBox "query: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if else MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if else MsgBox "This example is for Windows only." end if End EventHandler
Property w As WindowsWMIMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

See also:

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


The biggest plugin in space...