Solved

COM

Posted on 2000-03-11
5
239 Views
Last Modified: 2013-11-25
In inprocserver the methods that an interface expose is specified as pure virtual, therefore when the com class(implementation class) is instantiated the compiler generates Vtable which has address of the interface methods.Now the question is why should we use QuerryInterface() to get an interface pointer when we can get the address of Vtable and subsiquently get the method address?
0
Comment
Question by:r_sam_14
  • 5
5 Comments
 
LVL 5

Expert Comment

by:Wyn
ID: 2607821
->why should we use QuerryInterface() to get an interface pointer when we can get the address of Vtable and subsiquently get the method address
==========================
Put it simply,because QueryInterface is not only for get pointer but mainly for change the kind of the pointer to let it point to another interface.

Sure you can get pointer easily buy create it by yourself but it's against what COM is for.Com has the duty to create a class and cast it and pass pointer to you,it's not your duty.This is the main reason we use QueryInterface().

Regards
W.Yinan
0
 
LVL 5

Accepted Solution

by:
Wyn earned 30 total points
ID: 2607822
->why should we use QuerryInterface() to get an interface pointer when we can get the address of Vtable and subsiquently get the method address
==========================
Put it simply,because QueryInterface is not only for get pointer but mainly for change the kind of the pointer to let it point to another interface.

Sure you can get pointer easily buy create it by yourself but it's against what COM is for.Com has the duty to create a class and cast it and pass pointer to you,it's not your duty.This is the main reason we use QueryInterface().

Regards
W.Yinan
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2607828
I find your main problem is you forget we are using COM and it's a specification which give us the way to use COM.If you use it as common way,like you get pointer to interface by creating COM object in your code(client code),you are not using COM and you lose the points/benifits here.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2607859
->we can get the address of Vtable and subsiquently get the method address?
=================
Yes,you can do that if you know what you are doing clearly,like you know how different kinds of interfaces are structured in a class ,e.g:by multiple inherit or aggregation and so on,but it's not always the case,more often than not we dont know how they compose together.And again you are not using COM,it's standard we should obey to get pointer from QueryInterface and sometimes it's the only way.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2607870
->is instantiated the compiler generates Vtable which has address of the interface methods
==============================
No,compiler doesnt has it.Only thing it knows is the sequence of functions and the address will be filled at runtime.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why I am having this error installing Visual Basic Enterprise 11 58
wordappend challenge 8 150
Please explain "Multi-Tenant Services" 5 65
Message not shown 5 34
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now