Bewerken

Delen via


Retrieving Amended Classes Using the Scripting API for WMI

If you are using the Scripting API for WMI to retrieve or store localized class information, specify the locale as part of a moniker. Or, you can supply the locale name in the strLocale parameter to the SWbemLocator.ConnectServer method. When reading or writing amended classes, indicate that you want to use localized class definitions by specifying wbemFlagUseAmendedQualifiers as a flag for the iFlags parameter of the method you call. For PowerShell, you can use the -locale parameter on Get-WmiObject to specify the locale.

The following code example shows how to retrieve a localized class by using a WMI scripting moniker or the -locale parameter.

Set objwbemobject = GetObject("winmgmts:[locale=ms_409]!root/test:myclass")

Get-WmiObject myclass -Namespace "root\test" -Locale "ms_409"

The following code example shows how to set the locale parameter and use the wbemFlagUseAmendedQualifiers flag.

Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set service = Locator.ConnectServer(,"root\test", , , "ms_409")
Set objwbemobject = service.Get("myclass", wbemFlagUseAmendedQualifiers)

Note

Because the callback to the sink might not be returned at the same authentication level as the client requires, it is recommended that you use semisynchronous instead of asynchronous communication. For more information, see Calling a Method.

 

The following table lists the methods that accept the wbemFlagUseAmendedQualifiers flag.

Synchronous Method Asynchronous Method
SWbemServices.SubclassesOf SWbemServices.SubclassesOfAsync
SWbemObject.Subclasses_ SWbemObject.SubclassesAsync_
SWbemServices.InstancesOf SWbemServices.InstancesOfAsync
SWbemObject.Instances_ SWbemObject.InstancesAsync_
SWbemServices.ExecQuery SWbemServices.ExecQueryAsync
SWbemServices.Get SWbemServices.GetAsync
SWbemObject.Put_ SWbemObject.PutAsync_
SWbemServices.ReferencesTo SWbemServices.ReferencesToAsync
SWbemObject.References_ SWbemObject.ReferencesAsync_
SWbemServices.AssociatorsOf SWbemServices.AssociatorsOfAsync
SWbemObject.Associators_ SWbemObject.AssociatorsAsync_