Announcement

Collapse
No announcement yet.

COM Method Return Types

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
    Thomas Tierney
    Member

  • Thomas Tierney
    replied
    Looks like it can be done only if I create the IDL manually and then create the TLB seperately.


    Thanks ALL!

    Leave a comment:

  • Dominic Mitchell
    Member

  • Dominic Mitchell
    replied
    I don't think so, because for a dual interface, he wants something like this in the *.idl
    Code:
        [id(0x00000008), propget, helpstring("Returns/sets a value which specifies if a Node object is locked.")]
        HRESULT Locked([out, retval] VARIANT_BOOL* fLocked);
    Using low-level COM, this would be coded something like this
    Code:
    FUNCTION treeINode_get_Locked(BYVAL pThis AS DWORD, fLocked AS INTEGER) AS LONG
    
      LOCAL pttid     AS INode PTR
    
      pttid = pThis
    
      IF VARPTR(fLocked) = %NULL THEN
        FUNCTION = %E_POINTER
        EXIT FUNCTION
      END IF
    
      IF (@pttid.dwState AND %TIS_LOCKED) THEN
        fLocked = &HFFFF%
      ELSE
        fLocked = &H0000%
      END IF
    
      FUNCTION = %S_OK
    
    END FUNCTION
    How do we code this in PB9 COM to get the same output in the *.idl as shown above?

    Or, if this was a property, output similar to this
    Code:
    [id(0x00000002), helpstring("Sets or returns my flag."), helpcontext(0x000003f0)]
    VARIANT_BOOL MyBoolean;
    Dominic Mitchell
    Member
    Last edited by Dominic Mitchell; 5 Sep 2008, 08:47 AM.

    Leave a comment:

  • Steven Pringels 3
    Member

  • Steven Pringels 3
    replied
    Thomas,

    Maybe try

    Code:
    Method MyBoolean() as Variant
    
     Dim pVariant AS VARIANTAPI PTR
     Dim vBoolean as VARIANT
    
     pVariant = VarPtr(vBoolean)
     pVariant.vt = %VT_BOOLEAN
    
     vBoolean = 1 
    
     Method = vBoolean
    
    End Method
    Something like this ?

    Leave a comment:

  • Thomas Tierney
    Member

  • Thomas Tierney
    started a topic COM Method Return Types

    COM Method Return Types

    I would like to return a boolean value from a COM Method. This is essentially a VARIANT of type VT_BOOL. How do I tell the compiler to create this type in the typelib, or will I manually have to create the TYPELIB with this value?
Working...
X