QueryInterface( ..., void** ppv)
-
Hi, could anybody explain please the reason for QueryInterface's second parameter being a double pointer? Thanks PP
I believe it is so QueryInterface can return a pointer. Hope this helps, Bill
-
Hi, could anybody explain please the reason for QueryInterface's second parameter being a double pointer? Thanks PP
Hi, Let us start from the begining of the C/C++ language without COM. In the C/C++ language, whenever you have a class which contains at least ONE Virtual Function/Pure Function, a virtual table will be created at run time for this class which contains a list of the virtual functions in that class, and a Hidden pointer which called _vPtr is returned, this pointer points to the first entry in the virtual table. Let us back to the COM world, QueryInterface is a method in the IUnknown interface, and IUknown interface is accessing the functionality of the component through virtual table. The interface which returned from the QueryInterface is NOT poiting to the virtual table directly, it points to the hidden pointer _vPtr which points to the virtual table. For this reason we have pointer to pointer. ;) Regards, ShadiK. Shadi Al-Kahwaji