CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: QueryIntreface

  1. #1
    Join Date
    Mar 1999
    Posts
    22

    QueryIntreface



    Hello.

    If a COM Object has two intefaces, how do I reach the second interface from the first one, like you do with QueryInterface in C++ ?.


    Regards


    Martin

  2. #2
    Join Date
    May 1999
    Posts
    45

    Re: QueryIntreface



    If you want to do it C++ way I don't think it's possible. Maybe you can call C++ function & get pointer to the interface. But you won't be able to call functions as pointer arithmatic & calling functions by pointer is not possible in VB.

    So VB makes life easier by asking user to reference the type library at design time. That way it saves classids in design time. Then, it allows user to use interfaces as if they are classes. So you really don't get new interface pointer from other interface pointer you have. Instead (may be) VB gets all of them right in the beginning(???). So they are available all the time.

    User's job is to use them.




  3. #3
    Join Date
    Aug 1999
    Posts
    1

    Re: QueryIntreface


    If a coclass (ProgID is MyLib.Dog) implents two intefaces, iAnimal and iDog then you create an instange of Class Dog...

    Dim id as iDog 'declare pointer to interface
    Dim ia as iAnimal 'declare pointer to interface
    set id = new dog 'this creates a coclass of AND does QueryInterface to get its dog interface!
    set ia = id 'this does just QI and now we have access to the animal interface




    Also:

    If dog is typeof iAnimal then ...



    does QI on dog to see if it supports the iAnimal interface.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured