Announcement

Collapse
No announcement yet.

Get iEnumerator from nodelist

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

  • Get iEnumerator from nodelist

    I am trying to get me the nodes via the enumerator.
    problem is that the nodelist object is a late bound object.
    So i was trying to use the interface pointer -4 to call the enumvariant interface.
    Frankly i find the hard offsets a poor design.
    Any luck i can keep using the late bound object and fetch me the enumerator anyway?
    The enumerator is declared (early binding)

    I seen code using Queryinterface but does not return an object:
    Code:
        Local oUnk  As IUnknown    
        Local pEnum As Dword
        oUnk = oNodeList    
        oUnk.QueryInterface( $IID_IEnumVARIANT, pEnum ) To hr
    hellobasic

  • #2
    Maybe pEnum needs to be defined as a PTR variable type?

    As written, the compiler would pass a ptr to a DWORD, not a ptr to a ptr as required for iUnknown.queryInterface
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      I just found out that i misinterpret someone's code.
      This subject can be deleted, it's going nowhere.

      hellobasic

      Comment


      • #4
        Use:

        Code:
        LOCAL hr AS LONG
        LOCAL pEnum AS IEnumVARIANT
        LOCAL IID_IEnumVARIANT AS GUID
        IID_IEnumVARIANT = $IID_IEnumVARIANT
        hr = oNodeList.QueryInterface(IID_IEnumVARIANT, BYVAL VARPTR(pEnum))
        Forum: http://www.jose.it-berater.org/smfforum/index.php

        Comment


        • #5
          Oops, though that wasn't possible.
          When i took a closer look i was thinking you did this on the resulting interface.

          Could this mean i don't need the Invoke(-4) stuff for any late bound Dispatch interface?
          hellobasic

          Comment


          • #6
            This works:
            Code:
                    If oDisp.Invoke( -4, IID_NULL, 0, 1 Or 2, udispparams, vResult, ByVal VarPtr( pExcepInfo ), puArgErr ) = 0 Then
                        oEnum = vResult: vResult = Empty
                    End If
            This not:
            Code:
                    Local pUnk As Dword Ptr
                    If oDisp.QueryInterface($IID_IEnumVARIANT, ByVal VarPtr(pUnk)) = 0 Then
                    End If
            pUnk remains 0
            hellobasic

            Comment


            • #7
              For some reason, the built-in QueryInterface method does not work if you pass a constant. Use a variable as I did in my previous post:

              Code:
                      Local pUnk As Dword Ptr
                      Local IID_IEnumVARIANT As GUID
                      IID_IEnumVARIANT = $IID_IEnumVARIANT
                      If oDisp.QueryInterface(IID_IEnumVARIANT, ByVal VarPtr(pUnk)) = 0 Then
                      End If
              Forum: http://www.jose.it-berater.org/smfforum/index.php

              Comment


              • #8
                Cool!

                Much better than the invoke..
                hellobasic

                Comment


                • #9
                  But be aware that these built-in methods are undocumented...
                  Forum: http://www.jose.it-berater.org/smfforum/index.php

                  Comment


                  • #10
                    That is a compiler issue and solvable.
                    For me it's more important i can use this on any interface (unknown/dispatch) which supports the enumeration.

                    And -4 is a 'fixed' member also and i could use this but i like this better.

                    I also believe this will help me with non-dual interfaces.
                    hellobasic

                    Comment


                    • #11
                      Oh btw, i used call dword with vtable offsets, forgot to memtion.
                      I just rewrote it.
                      hellobasic

                      Comment


                      • #12
                        is it possible to implement this enumerator interface into PB classes?
                        Maybe simply adding it icw it's guid?
                        I don't have much influence on the QueryInterface is it?
                        hellobasic

                        Comment


                        • #13
                          The classic way is to add the _NewEnum method/property to your collection class and, in that method, return a pointer to your implementation of the IEnumVARIANT class. Calling QueryInterface for IEnumVARIANT won't work if the enumerator isn't implemented in the same class.
                          Forum: http://www.jose.it-berater.org/smfforum/index.php

                          Comment


                          • #14
                            Could this mean i don't need the Invoke(-4) stuff for any late bound Dispatch interface?
                            Calling the _NewEnum method (dispID -4) is the safer way, and the only that will work if you write a component to be used by languages such VB that use the FOR EACH construct.
                            Forum: http://www.jose.it-berater.org/smfforum/index.php

                            Comment


                            • #15
                              I'll make this the 2nd option then.
                              Thanks,
                              hellobasic

                              Comment

                              Working...
                              X