#88297 - 2002-09-26 02:54 PM
KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Chris - hope you don't mind but I'm hijacking your KiXomatic code (read stealing) for use in the first forms ListView script. This application really lends itself to this kind of presentation ...
Anyways .. that EnumClasses thingy you wrote ... have you posted that to the UDF forum ... is there already one like it there. Just as an FYI and in terms of experimentation - I modified your function to get make it more generic (passing the class filter as a parm) plus, returning an array of class strings plus - passing a reference to an optional progress bar (instead of hard coding it) ... just thought I would open-up a dialog because I really like your KiXomatic script ...
Usage (Forms 2.1):
code:
For Each $Class In WmiEnumClasses("WIN32_",$Progress) $Item = $ClassList.Items.Add($Class) Next
Script:
code:
Function WmiEnumClasses(Optional $Filter, Optional $Progress) If Not $Filter $Filter = "WIN32_" Endif Dim $WMI,$Class,$Qualifier,$IsQ Dim $Bounds,$Count,$Increment Dim $Array[400] $Count = 0 $Increment = 100 $Bounds = UBound($Array) $WMI = GetObject("winmgmts:\\.\root\cimv2") If $Progress $Progress.Min = 0 $Progress.Max = 0 $Progress.Value = 0 For Each $Class in $WMI.SubclassesOf() $Progress.Max = $Progress.Max + 1 Next EndIf For Each $Class in $WMI.SubclassesOf() $Progress.Value = $Progress.Value + 1 $IsQ = 0 If Instr($Class.Path_.Class,$Filter); For Each $Qualifier in $objClass.Qualifiers_ If Instr($Qualifier.Name, "ASSOCIATION") $IsQ = 1 Endif Next If $IsQ = 0 $Array[$count] = $Class.Path_.Class $Count = $Count + 1 If $Count > $Bounds $Bounds = $Bounds + $Increment ReDim Preserve $Array[$Bounds] EndIf EndIf EndIf Next If $Count ReDim Preserve $Array[$Count-1] EndIf If $Progress $Progress.Value = 0 EndIf $WmiEnumClasses = $Array $WMI = 0 EndFunction
[ 26. September 2002, 15:23: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#88298 - 2002-09-26 03:25 PM
Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
ps. With the olde ListBox object - can simply say this now:
code:
$ClassList.List = WmiEnumClasses("WIN32_",$Progress)
[ 26. September 2002, 15:26: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#88300 - 2002-09-26 05:57 PM
Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Here's kinda where I'm heading with this ... hope it works (if you try it) because I'm running 2.1 here - hope I'm not using any of the new methods or properties ... should work under 2.0
Couple of things ... Its got an embedded progress bar in the status bar (kinda like IE) and its got a realtime clock in the status bar ... other than that ... just lists the WMI classes right now.
code:
Break On $TITLE = "WmiList" $WIDTH = 400 $HEIGHT = 300 $MARGIN = 4 $Form = CreateObject("Kixtart.Form") $Form.ClientWidth = $WIDTH $Form.ClientHeight = $HEIGHT $Form.FontSize = 10 $Form.Caption = $TITLE $Status = $Form.Label() $Status.Left = $MARGIN $Status.Top = $Form.ClientHeight - 25 $Status.Width = 0.4 * $Form.ClientWidth $Status.Height = 20 $Status.BorderStyle = 5 $Status.Text = "Ready..." $Progress = $Form.ProgressBar() $Progress.Left = $Status.Right + $MARGIN $Progress.Top = $Form.ClientHeight - 25 $Progress.Width = 0.4 * $Form.ClientWidth $Progress.Height = 20 $Progress.BorderStyle = 5 $Progress.ForeColor = 0,200,0 ; Green $Clock = $Form.Label() $Clock.Left = $Progress.Right + $MARGIN $Clock.Top = $Form.ClientHeight - 25 $Clock.Width = $Form.ClientWidth-$Progress.Right-$MARGIN*2 $Clock.Height = 20 $Clock.BorderStyle = 5 $Clock.Text = "Ready..." $Timer = $Form.Timer(1000) $Timer.OnTimer = "OnTimer()" Function OnTimer() $Clock.Text = @TIME EndFunction $List = $Form.ListBox $List.Sorted = 1 $List.Top = 5 $List.Left = 5 $List.Right = $Form.ClientWidth - $MARGIN $List.Bottom = $Status.Top - $MARGIN $Form.Center $Form.Show $Form.MousePointer = 11 $Form.Enabled = 0 $Status.Text = "Loading classes..." $List.List = WmiEnumClasses("WIN32_",$Progress) $Status.Text = "Ready" $Form.Enabled = 1 $Form.MousePointer = 0 While $Form.Visible $= Execute($Form.DoEvents) Loop Exit 1 Function WmiEnumClasses(Optional $Filter, Optional $Progress) If Not $Filer $Filter = "WIN32_" Endif Dim $WMI,$Class,$Qualifier,$IsQ Dim $Bounds,$Count,$Increment Dim $Array[400] $Count = 0 $Increment = 100 $Bounds = UBound($Array) $WMI = GetObject("winmgmts:\\.\root\cimv2") If $Progress $Progress.Min = 0 $Progress.Max = 0 $Progress.Value = 0 For Each $Class in $WMI.SubclassesOf() $Progress.Max = $Progress.Max + 1 Next EndIf For Each $Class in $WMI.SubclassesOf() $Progress.Value = $Progress.Value + 1 $IsQ = 0 If Instr($Class.Path_.Class,$Filter); For Each $Qualifier in $objClass.Qualifiers_ If Instr($Qualifier.Name, "ASSOCIATION") $IsQ = 1 Endif Next If $IsQ = 0 $Array[$count] = $Class.Path_.Class $Count = $Count + 1 If $Count > $Bounds $Bounds = $Bounds + $Increment ReDim Preserve $Array[$Bounds] EndIf EndIf EndIf Next If $Count ReDim Preserve $Array[$Count-1] EndIf If $Progress $Progress.Value = 0 EndIf $WmiEnumClasses = $Array $WMI = 0 EndFunction
|
|
Top
|
|
|
|
#88304 - 2002-09-26 06:30 PM
Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
yap - the 2.1 version has the listbox pushed over to the left a little - next to that is a ListView grid that behaves like the property sheet from VB or VBA ... know what I mean ? Column one is called "Property" and column two is called "Value". The intent is to enumerate the selected classes properties into the property sheet view. A WMI browser yeah ... after that ... ahhh ... i don't know what
|
|
Top
|
|
|
|
#88305 - 2002-09-26 06:37 PM
Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
I added a...
$List.Width = 0.33 * $Width
to make the listbox dynamic too.
|
|
Top
|
|
|
|
#88307 - 2002-09-26 06:50 PM
Re: KiXomatic 2.0 - Revised WmiEnumClasses with ProgressBar
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Found the bug in WMIEnumClasses()
code:
For Each $Qualifier in $objClass.Qualifiers_
Should be...
code:
For Each $Qualifier in $Class.Qualifiers_
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 657 anonymous users online.
|
|
|