Rami Loiferman Rami Loiferman - 1 year ago 71
Java Question

How to access an IUnknown com interface on com

As I understand, every program that is using com communication has to implement IUnknown interface.

The query interface method is the method that calls to the query interface.

My question is how can I use this method or access this IUnknown interface,
Using Jacob jar or even with vbscript?

If possible I'd like a code example in vbscript.

Answer Source
Set x = CreateObject("Object.Name")

That's VBScript.

This is from help in the Appendix of the Automation Programming Reference. Note VBS only does GetObject/CreateObject. So CoCreateInstance gets IUnknown. Which is then used to query for IDispatch. All other interfaces inheiret from IUnknown so you queryref on any interface as IUnknown's methods are in every interface.

  **Component Automation**  

Mapping Visual Basic to Automation

Visual Basic provides full support for Automation. The following table lists how Visual Basic statements translate into OLE APIs.

Visual Basic statement  OLE APIs  

CreateObject (ProgID)


QueryInterface to get IDispatch interface.

GetObject (filename, ProgID)


QueryInterface for IPersistFile interface.

Load on IPersistFile interface.

QueryInterface to get IDispatch interface. 

GetObject (filename)
 CreateBindCtx creates the bind context for the subsequent functions.

MkParseDisplayName returns a moniker handle for BindMoniker.

BindMoniker returns a pointer to the IDispatch interface.

Release on moniker handle.

Release on context.

GetObject (ProgID)

GetActiveObject on class ID.

QueryInterface to get IDispatch interface. 

Dim x As New interface
 Find CLSID for interface.



 © Microsoft Corporation. All rights reserved.  
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download