locked
QueryInterface RRS feed

  • Question

  • Why does COM'S QueryInterface pointer take a void** input parameter and not return a output void* paramter instead?

    Why not a void* QueryInterface(  REFIID iid) instead of the current form?

     

    Are there any design issues with such an implementation other than it doesn't allow the HRESULT to return colorful error codes?

    Tuesday, March 4, 2008 12:43 AM

Answers

  •  homeland wrote:

    Why does COM'S QueryInterface pointer take a void** input parameter and not return a output void* paramter instead?

    Why not a void* QueryInterface(  REFIID iid) instead of the current form?

     

     

    All COM method calls return an HRESULT. It would look odd if QueryInterface() did not return an HRESULT, and in fact would complicate most server code to make a special case if it didn't. After all, all interfaces derive from IUnknown* and therefore all interfaces must implement it.

     

     homeland wrote:

    Are there any design issues with such an implementation other than it doesn't allow the HRESULT to return colorful error codes?

     

    There has to be some way of returning additional error/warning/notational information if the method call doesn't go the way the client code expects. This was the way the COM designers chose. Out of curiosity, how would you design it?

     

    Brian

     

    Tuesday, March 4, 2008 2:14 AM
  • Are there any design issues with such an implementation other than it doesn't allow the HRESULT to return colorful error codes?

     

    COM is a powerfull framework but the complexity it handles is very huge...  Normal Inprocess or outprocess COM wont give you much pain, but if u deside to code a Distributed COM Server you will really need this HRESULT. (right from faulty connection to a security issues and a lot more problems ) and the possibility of errors that can happen while developing and testing a Distributed COM component are many. A small careless mistake while coding or configuration can make u lost. Here the HRESULT returned by the COM methods come to your rescue. Always make it a habbit to check this return code while you develope a COM component, Belive me it can save you a lot of time

     

     

    Regards

    Bijo.

    Tuesday, March 4, 2008 1:32 PM

All replies

  •  homeland wrote:

    Why does COM'S QueryInterface pointer take a void** input parameter and not return a output void* paramter instead?

    Why not a void* QueryInterface(  REFIID iid) instead of the current form?

     

     

    All COM method calls return an HRESULT. It would look odd if QueryInterface() did not return an HRESULT, and in fact would complicate most server code to make a special case if it didn't. After all, all interfaces derive from IUnknown* and therefore all interfaces must implement it.

     

     homeland wrote:

    Are there any design issues with such an implementation other than it doesn't allow the HRESULT to return colorful error codes?

     

    There has to be some way of returning additional error/warning/notational information if the method call doesn't go the way the client code expects. This was the way the COM designers chose. Out of curiosity, how would you design it?

     

    Brian

     

    Tuesday, March 4, 2008 2:14 AM
  • Are there any design issues with such an implementation other than it doesn't allow the HRESULT to return colorful error codes?

     

    COM is a powerfull framework but the complexity it handles is very huge...  Normal Inprocess or outprocess COM wont give you much pain, but if u deside to code a Distributed COM Server you will really need this HRESULT. (right from faulty connection to a security issues and a lot more problems ) and the possibility of errors that can happen while developing and testing a Distributed COM component are many. A small careless mistake while coding or configuration can make u lost. Here the HRESULT returned by the COM methods come to your rescue. Always make it a habbit to check this return code while you develope a COM component, Belive me it can save you a lot of time

     

     

    Regards

    Bijo.

    Tuesday, March 4, 2008 1:32 PM
  • HI Guys

    Thanks for the replies..and sorry for the delay in responding. I had designed my interface inspired from IUnknown and when asked why i am taking a double pointer as paramter instead of returning a pointer to interface I didn't have a good reply Smile

    BR

    V

     

    Saturday, March 15, 2008 1:29 PM