Click to See Complete Forum and Search --> : QueryIntreface


Martin
March 16th, 1999, 08:33 AM
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

Vinayak Sapre
March 16th, 1999, 07:32 PM
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.

Martin Pyle
August 25th, 1999, 12:25 PM
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.