COMDispFunction.new Method

Creates a COMDispFunction object, which is used to access the functionality in an Automation object.

Syntax

public void new(
    COM comObject, 
    str functionName, 
    COMDispContext context)

Run On

Called

Parameters

  • comObject
    Type: COM Class
    The Automation object.
  • functionName
    Type: str
    The name of the functionality to access.
  • context
    Type: COMDispContext Enumeration
    The context of the functionality to access; one of the following values: COMDispContext::METHODCOMDispContext::PROPERTYGETCOMDispContext::PROPERTYPUTCOMDispContext::PROPERTYPUTREF

Remarks

It is important to specify the correct context of the functionality in the COM object to access. The reason for this is because a COM object can supply up to four functions that use the same name. Due to the possible name clashing, the context is used to distinguish the method or properties. To specify the correct context, see the documentation for the COM object in question.

Examples

{ 
    InteropPermission perm; 
    COM com; 
    COMDispFunction funcShow; 
    COMDispFunction getValue; 
    COMDispFunction putValue; 
    ; 
  
    perm = new InteropPermission(InteropKind::ComInterop); 
    perm.assert(); 
    com = new COM("MyCOM.Object"); 
    funcShow = 
        new COMDispFunction(com, "show",  COMDispContext::METHOD); 
    getValue = 
        new COMDispFunction(com, "value", COMDispContext::PROPERTYGET); 
    putValue = 
        new COMDispFunction(com, "value", COMDispContext::PROPERTYPUT); 
}

See Also

COMDispFunction Class

COMDispFunction.call Method

COM Class