Announcement

Collapse
No announcement yet.

COM Method Return Types

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?
    Sr. Software Development Engineer and Sr. Information Security Analyst,
    CEH, Digital Forensic Examiner

  • #2
    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 ?
    So here we are, this is the end.
    But all that dies, is born again.
    - From The Ashes (In This Moment)

    Comment


    • #3
      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;
      Last edited by Dominic Mitchell; 5 Sep 2008, 07:47 AM.
      Dominic Mitchell
      Phoenix Visual Designer
      http://www.phnxthunder.com

      Comment


      • #4
        Looks like it can be done only if I create the IDL manually and then create the TLB seperately.


        Thanks ALL!
        Sr. Software Development Engineer and Sr. Information Security Analyst,
        CEH, Digital Forensic Examiner

        Comment

        Working...
        X