[This is preliminary documentation and subject to change.]
The syntax for an object path to an instance with a single key property is as follows:
<server><namespace>:<classname>.<key property>=<key>
For an instance that includes multiple key properties, the syntax is:
<server><namespace>:<classname>.<key property>=<key>,
<keyproperty>=<key>, etc...
The following table describes the items in the object path syntax:
Object path syntax item | Description |
---|---|
<server> | A double leading backslash followed by the network name of the machine. |
<namespace> | Object path to the appropriate namespace on the server specified by <server>. |
<classname> | Relative object path to the instance within the namespace. |
<key property> | Name of the property that serves as the key for the instance. |
<key> | Value of the key property. |
When accessing an instance that resides on the current server and in the current namespace, all that is necessary is the classname and key. For example, the following object paths point to single instances in the current namespace on the current server:
LogicalDisk="E:"
ComPort=2
To retrieve a particular instance, use code similar to the following sample. The call to SysAllocString allocates and initializes the character string for the object path.The call to IWbemServices::GetObject retrieves the instance and places it in the contents of the pComPort parameter.
BSTR Path = SysAllocString(L"ComPort=2");
IWbemClassObject *pComPort = 0;
pWbemSvcs->GetObject(Path, 0, 0, &pComPort, 0);
For instances of classes that specify multiple properties as the key, there is no implied ordering of properties that make up the key. It is necessary to specify the value of each of the properties in the object path. For example, assume that the class MyClass2 has a compound key consisting of an integer property IntVal and a string property StrVal. The following object paths show two different ways to identify the same instance of MyClass2:
"MyClass.IntVal=33,StrVal=\"AAA\""
"MyClass.StrVal=\"AAA\",IntVal=33"
Notice that because of the embedded quotes, the escape character must be used, as in a C-language or Microsoft® Visual C++® program.
Object paths to instances are used in calls to:
Note Only decimal integers of type VT_I4, Booleans of type VT_BOOL, and strings of type VT_BSTR can act as keys or parts of compound keys. Other key types, including arrays, are not permitted. Within the object path string, only decimal values are recognized as numeric portions of keys. Escaped quotes are permitted as part of an object path if embedded quotes are required.