Редактиране

Споделяне чрез


SWbemRefreshableItem object

The SWbemRefreshableItem object represents a single item in an SWbemRefresher object. An SWbemRefreshableItem object is obtained through the Add and AddEnum methods of SWbemRefresher. This object cannot be created by the VBScript CreateObject call.

Members

The SWbemRefreshableItem object has these types of members:

Methods

The SWbemRefreshableItem object has these methods.

Method Description
Remove Removes the SWbemRefreshableItem object from the parent SWbemRefresher object.

Properties

The SWbemRefreshableItem object has these properties.

Property Access type Description
Index
Read/write
Index of the item in its parent SWbemRefresher object.
IsSet
Read/write
Indicates whether the SWbemRefreshableItem object represents a single object or an object set.
Object
Read/write
Represents a single SWbemObject object that is refreshed.
ObjectSet
Read/write
Represents the object set to be refreshed.
Refresher
Read-only
Represents the parent SWbemRefresher object which contains the SWbemRefreshableItem object.

Remarks

The VBScript method GetObject cannot be used to create SWbemRefreshableItem objects directly.

Examples

The following script illustrates the creation of an SWbemRefresher object and the addition of single object and enumerator SWbemRefreshableItem to it.

' Get some namespace connections
set cimv2 = GetObject("winmgmts:root\cimv2")
set default = GetObject("winmgmts:root\default")    

' Create a refresher
set refresher = CreateObject("WbemScripting.SWbemRefresher")

' Add a single object to the refresher.
' The @ is used because this is a singleton 
' system class so only one instance exists.
set item1 = refresher.Add (default, "__CIMOMIdentification=@").Object
MsgBox "WMI Version " item1
' Add an enumerator to the refresher.
' Note that the SWbemRefreshableItem.ObjectSet 
' property must be used to designate
' this as an object set rather than a single object.
set item2 = refresher.AddEnum (cimv2, "Win32_Process").ObjectSet

' Loop three times, refreshing the items

For I= 1 To 3
MsgBox "Refresh number " & I
refresher.Refresh

' Iterate through the collection of
' processes in item2 with name of wscript
    For each process in item2
        If process.name = "wscript.exe" then
        MsgBox "Process " & process.Name & _
           " Page Faults " & process.PageFaults
        End If
    Next 
Next

' Clear out the refresher
refresher.DeleteAll 

' The following should return 0
MsgBox "Number of items in Refresher after DeleteAll " _
    & refresher.Count

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
Wbemdisp.h
Type library
Wbemdisp.tlb
DLL
Wbemdisp.dll
CLSID
CLSID_SWbemRefreshableItem
IID
IID_ISWbemRefreshableItem

See also

Scripting API Objects