Help for WMI required
I need some help to receive the required information according to my physical media inside the cdrom drive:
I use the following VB Scriped:
'Add Reference to Microsoft WMI Scripting V1.2 Lib
'Add RTF Control name : ctr_WMIParse
'Add ComboBox name : ctr_WMICLass
'Add Command B. name : cmd_WMI
'Add Command B. name : cmd_Quit
'
'You can add any WIN32 or CIM Class based on root/cimv2 in the form_load sub
Private oService As SWbemServices 'WMI Service Object
Private oSet As SWbemObjectSet 'WMI Object collection
Private oWMI As SWbemObject 'WMI Object
Private s_Server As String
Private Sub cmd_Quit_Click()
Unload Me
End Sub
Private Sub cmd_WMI_Click()
On Error GoTo Err_cmd_WMI_Click
Dim s_Query As String
'Reset Parse
Me.ctr_WMIParse.Text = ""
'Call WMI Interface
s_Query = "Select * from " & Me.ctr_WMICLASS.Text & " "
Set oSet = oService.ExecQuery(s_Query, , (wbemFlagReturnImmediately Or _
wbemFlagForwardOnly))
For Each oWMI In oSet
Me.ctr_WMIParse.Text = Me.ctr_WMIParse.Text & _
oWMI.GetObjectText_ & vbCrLf & vbCrLf
Next
Exit_cmd_WMI_Click:
Set oWMI = Nothing
Set oSet = Nothing
Exit Sub
Err_cmd_WMI_Click:
MsgBox Err.Description
Resume Exit_cmd_WMI_Click
End Sub
Private Sub Form_Load()
On Error GoTo Err_Form_Load
'Init ctr_Parse
Me.ctr_WMIParse.Text = ""
'Init ctr_Class
Me.ctr_WMICLASS.Clear
Me.ctr_WMICLASS.AddItem "WIN32_DiskDrive"
Me.ctr_WMICLASS.AddItem "WIN32_LogicalDisk"
Me.ctr_WMICLASS.AddItem "WIN32_CDROMDrive"
Me.ctr_WMICLASS.AddItem "WIN32_PhysicalMedia"
Me.ctr_WMICLASS.ListIndex = Me.ctr_WMICLASS.ItemData(0)
'Init WMI
s_Server = "."
Set oService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate," _
& "authenticationLevel=pktPrivacy}!" _
& "\\" & s_Server & "\root\cimv2")
Exit_Form_Load:
Exit Sub
Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Load
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set oService = Nothing
Set oSet = Nothing
Set oWMI = Nothing
End Sub
If I calling the class WIN32_LogicalDisk or WIN32_CDROMDrive than I will receive the CDROM information, but the WIN32_PhysicalMedia does not include any information about my CDROM.
I am using a notebook brand vaio with WINXP Professional V6.

