Help Center

CDispInvoke.Getmethod

Calls the specified property of an interface and gets the value returned.

COMmethodCDispInvoke.incdocumented

Syntax

FUNCTION Get (BYVAL dispID AS DISPID) AS DVARIANT
FUNCTION Get (BYVAL dispID AS DISPID, BYREF dvArg AS DVARIANT) AS DVARIANT
FUNCTION Get (BYVAL dispID AS DISPID, BYREF dvArg1 AS DVARIANT, BYREF dvArg2 AS DVARIANT) AS DVARIANT
FUNCTION Get (BYVAL pwszName AS WSTRING PTR) AS DVARIANT
FUNCTION Get (BYVAL pwszName AS WSTRING PTR, BYREF dvArg AS DVARIANT) AS DVARIANT
FUNCTION Get (BYVAL pwszName AS WSTRING PTR, BYREF dvArg1 AS DVARIANT, BYREF dvArg2 AS DVARIANT) AS DVARIANT

Parameters

NameDescription
dispIDIdentifies the member. Use GetIDsOfNames or the object's documentation to obtain the dispatch identifier.
pwszNameThe name of the property to call.
dvArg1DVARIANT. First argument.
dvArg2DVARIANT. Second argument.

Return value

The property value.

Description

Calls the specified property of an interface and gets the value returned. The overloaded methods allow to use the Get method passing one argument, two arguments or none.

Example

#include "windows.bi" #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" IF pServices.ServicesPtr = NULL THEN END ' // Execute a query DIM hr AS HRESULT = pServices.ExecQuery("SELECT Caption, SerialNumber FROM Win32_BIOS") IF hr <> S_OK THEN PRINT AfxWmiGetErrorCodeText(hr) : SLEEP : END ' // Get the number of objects retrieved DIM nCount AS LONG = pServices.ObjectsCount print "Count: ", nCount IF nCount = 0 THEN PRINT "No objects found" : SLEEP : END ' // Enumerate the objects using the standard IEnumVARIANT enumerator (NextObject method) ' // and retrieve the properties using the CDispInvoke class. DIM pDispServ AS CDispInvoke = pServices.NextObject IF pDispServ.DispPtr THEN PRINT "Caption: "; pDispServ.Get("Caption") PRINT "Serial number: "; pDispServ.Get("SerialNumber") END IF PRINT PRINT "Press any key..." SLEEP

Reference

  • Include file CDispInvoke.inc
  • Defined in AfxNova/CDispInvoke.inc:801
  • Documented in COM/CDispInvoke Class.md
  • Topic: CDispInvoke Class