GetNamedPropertiesfunction
Retrieves a named collection of the properties for the current class or instance.
Syntax
FUNCTION GetNamedProperties (BYVAL idx AS LONG = 0) AS HRESULT
Parameters
| Name | Description | |
|---|---|---|
idx | The zero-based index of the member of the collection. |
Return value
S_OK on success or an error code.
May return one of the error codes in the following list:
Description
Retrieves a named collection of the properties for the current class or instance.
Examples
#include "AfxNova/CWmiDisp.inc" USING AfxNova
' // Connect to WMI using a moniker ' // Note: $ is used to avoid the pedantic warning of the compiler about escape characters DIM pServices AS CWmiServices = $"winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2"
' // Execute a query DIM hr AS HRESULT = pServices.ExecQuery("SELECT Caption, SerialNumber FROM Win32_BIOS")
' // Get the number of objects retrieved DIM nCount AS LONG = pServices.ObjectsCount print "Number of objects: ", nCount
' // Get a collection of named properties IF pServices.GetNamedProperties <> S_OK THEN PRINT "Failed to get the named properties"
' // Retrieve the value of the properties PRINT pServices.PropValue("Caption") PRINT pServices.PropValue("SerialNumber")
#include "AfxNova/CWmiDisp.inc" USING AfxNova
' // Connect to WMI using a moniker ' // Note: $ is used to avoid the pedantic warning of the compiler about escape characters DIM pServices AS CWmiServices = $"winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2"
' // Execute a query DIM hr AS HRESULT = pServices.ExecQuery("SELECT * FROM Win32_Printer")
' // Get the number of objects retrieved DIM nCount AS LONG = pServices.ObjectsCount print "Number of objects: ", nCount
' // Enumerate the objects FOR i AS LONG = 0 TO nCount - 1 PRINT "--- Index " & STR(i) & " ---" ' // Get a collection of named properties IF pServices.GetNamedProperties(i) = S_OK THEN
PRINT pServices.PropValue("Caption")
PRINT pServices.PropValue("Capabilities")
END IF NEXT
Using a loop:
Reference
- Include file
CWmiDisp.inc - Documented in COM/CWmiDisp Class.md
- Topic: Windows Management Instrumentation (WMI)