COM Plug-in for Eclipse
September 09, 2010, 01:03:44 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: how to QueryInterface??  (Read 2582 times)
sspranay
Guest
« on: June 20, 2007, 05:42:42 AM »

I am sorry if am posting a query that is not directly related to this forum...
I am using SWT Ole automation.
am  queryInterfacing an IDispatch obj for an interface, but the return int = some negative value
also the int[] obj has null value that is supposed to carry the pointer to the interface queried...
where possibly I could be going wrong?
Any pointer would be a great help.

Thanks!
Logged
Mark Richter
Global Moderator
Full Member
*****
Posts: 137


View Profile
« Reply #1 on: June 20, 2007, 07:07:59 PM »

It could be that you do not need to QueryInterface or are using the wrong automation object to query the interface.  SWT does some calls QueryInterface behind the scenes and hence the OleAutomation object you are using may not be an IDispatch.  Also the COM CoClasses generated by SWTtoCOM have getAs.... methods for cast to various interfaces. 

The negative value returned from the method is an error code. Have a look at this url for more details on what the error code is http://support.microsoft.com/kb/186063
Logged
sspranay
Guest
« Reply #2 on: June 21, 2007, 10:23:17 AM »

Thanks for the reply Mark...
My returned error code reads - no such Interface supported.
Here is my dirty code snippet...

----------------
Variant IDispatchObj1 = Iprocess.getProperty(dispIdMember23);
   //this returned variant is an IDispatch interface that should be QueryInterfaced for
   // an IExportTextFormat Interface
   
   
   int[] ppvObject = new int[1];
   GUID IID_IExportTextFormats = COMObject.IIDFromString("{FA171E68-8E90-4F5F-9320-9FB7DF22D1AE}");
    // -2147467262 - no such interface supported!
   
   int resultQI = (IDispatchObj1.getDispatch()).QueryInterface(IID_IExportTextFormats, ppvObject);   
   
   //Returns a pointerObj to the requested interface, in this case the IExportTextFormat interface, if the interface is supported.
   //the properties(Count,Item) of the current export format (file type)  can b retrieved from this IDispatch Interface

----------------

Could you please tell me where the code is going wrong?
The automation documentation asks me to QueryInterface the returned IDispatch Interface as commented in the code..

Logged
Mark Richter
Global Moderator
Full Member
*****
Posts: 137


View Profile
« Reply #3 on: June 24, 2007, 01:26:07 AM »

Your code looks ok to me, however I am surprised that you need to query the interface after calling the property getter method.  In most cases these types of methods returned an IDispatch that implements the specified interface so you do not need to call query interface.  The error message returned also appears to indicate this may be the case.

Are you using a easily accessible public type library?  If so tell me which one and I will investigate further by replicating the problem.

-Mark
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!