Announcement

Collapse
No announcement yet.

Undefined Type when returning an object from an Interface Method

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

  • Undefined Type when returning an object from an Interface Method

    Hey all,

    I am trying to return an object from a method call and cant figure out how to do it.

    If I add the statment to my class
    Code:
       INTERFACE ITEST GUID$("{6D7C6252-F8AE-4DCD-90A9-EA97A0C0ACC6}")
            INHERIT IUNKNOWN
            METHOD SAVESETTINGS ALIAS "Save"() AS OBJECT
            END METHOD
        END INTERFACE

    I get an error that OBJECT is an undefined Type. I would much prefer to do a
    AS MYNEWCLASSITEM but apparently that isnt supported.

    Any help would be appreciated.
    Thanks
    Sr. Software Development Engineer and Sr. Information Security Analyst,
    CEH, Digital Forensic Examiner

  • #2
    Thomas,

    What about ... As IDispatch ?

    Cheers

    Steven
    So here we are, this is the end.
    But all that dies, is born again.
    - From The Ashes (In This Moment)

    Comment


    • #3
      I'm not quite sure what you are trying to do but:
      AS ITEST


      METHOD = OBJPTR(ME)

      James

      Comment


      • #4
        I Tried with IDISPATCH and it allowed me to compile but the typelib created

        interface IITEST : IUnknown {
        IUnknown _stdcall Save();
        };

        which isnt IDISPATCH. when I switch to IDISPATCH for both Inherit and the method result I get

        interface IITEST : IDispatch {
        [id(0x00000101)]
        HRESULT Save([out, retval] IDispatch** );
        };

        which is correct. So I must inherit IDISPATCH in the Interface in Order to return a dispatch object?

        Code:
        INTERFACE IITEST GUID$("{6D7C6252-F8AE-4DCD-90A9-EA97A0C0ACC6}")
                INHERIT IDISPATCH
                METHOD SAVESETTINGS ALIAS "Save"() AS IDISPATCH
                END METHOD
            END INTERFACE
        Sr. Software Development Engineer and Sr. Information Security Analyst,
        CEH, Digital Forensic Examiner

        Comment


        • #5
          Thomas,

          You can always return either IUnknown or IDispatch regardless of the
          class' heritage.

          It depends on what you're instantiating in the class itself. F.i. if you have a
          instance variable defined as IUnknown and obtain a reference from that,
          the Save method could return the IUnknown pointer to the instantiated
          variable. Same for IDispatch.

          Cheers
          Last edited by Steven Pringels 3; 4 Sep 2008, 02:43 AM.
          So here we are, this is the end.
          But all that dies, is born again.
          - From The Ashes (In This Moment)

          Comment


          • #6
            Hey Steven,

            Problem is, in order for the TypeLib to have the correct information in it I must set the Interface inheritance to IDISPATCH and the return value to IDISPATCH. If the Interface is IUNKNOWN then even with the return Value is IDISPATCH it will only return IUNKNOWN.

            And I have yet to find a TypeLib Def with

            interface IITEST : IUnknown {
            IUnknown _stdcall Save();
            };
            Sr. Software Development Engineer and Sr. Information Security Analyst,
            CEH, Digital Forensic Examiner

            Comment

            Working...
            X