| java.lang.Object org.eclipse.swt.ole.win32.OleAutomation
OleAutomation | final public class OleAutomation (Code) | | OleAutomation provides a generic mechanism for accessing functionality that is
specific to a particular ActiveX Control or OLE Document.
The OLE Document or ActiveX Control must support the IDispatch interface in order to provide
OleAutomation support. The additional functionality provided by the OLE Object is specified in
its IDL file. The additional methods can either be to get property values (getProperty ),
to set property values (setProperty ) or to invoke a method (invoke or
invokeNoReply ). Arguments are passed around in the form of Variant
objects.
Here is a sample IDL fragment:
interface IMyControl : IDispatch
{
[propget, id(0)] HRESULT maxFileCount([retval, out] int *c);
[propput, id(0)] HRESULT maxFileCount([in] int c);
[id(1)] HRESULT AddFile([in] BSTR fileName);
};
An example of how to interact with this extended functionality is shown below:
OleAutomation automation = new OleAutomation(myControlSite);
// Look up the ID of the maxFileCount parameter
int[] rgdispid = automation.getIDsOfNames(new String[]{"maxFileCount"});
int maxFileCountID = rgdispid[0];
// Set the property maxFileCount to 100:
if (automation.setProperty(maxFileCountID, new Variant(100))) {
System.out.println("Max File Count was successfully set.");
}
// Get the new value of the maxFileCount parameter:
Variant pVarResult = automation.getProperty(maxFileCountID);
if (pVarResult != null) {
System.out.println("Max File Count is "+pVarResult.getInt());
}
// Invoke the AddFile method
// Look up the IDs of the AddFile method and its parameter
rgdispid = automation.getIDsOfNames(new String[]{"AddFile", "fileName"});
int dispIdMember = rgdispid[0];
int[] rgdispidNamedArgs = new int[] {rgdispid[1]};
// Convert arguments to Variant objects
Variant[] rgvarg = new Variant[1];
String fileName = "C:\\testfile";
rgvarg[0] = new Variant(fileName);
// Call the method
Variant pVarResult = automation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
// Check the return value
if (pVarResult == null || pVarResult.getInt() != OLE.S_OK){
System.out.println("Failed to add file "+fileName);
}
automation.dispose();
|
Constructor Summary | |
public | OleAutomation(IDispatch idispatch) | public | OleAutomation(OleClientSite clientSite) Creates an OleAutomation object for the specified client. |
Method Summary | |
public void | dispose() Disposes the automation object. | int | getAddress() | public String | getDocumentation(int dispId) | public OleFunctionDescription | getFunctionDescription(int index) | public String | getHelpFile(int dispId) | public int[] | getIDsOfNames(String[] names) Returns the positive integer values (IDs) that are associated with the specified names by the
IDispatch implementor. | public String | getLastError() Returns a description of the last error encountered. | public String | getName(int dispId) | public String[] | getNames(int dispId, int maxSize) | public Variant | getProperty(int dispIdMember) Returns the value of the property specified by the dispIdMember. | public Variant | getProperty(int dispIdMember, Variant[] rgvarg) Returns the value of the property specified by the dispIdMember.
Parameters: dispIdMember - the ID of the property as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. | public Variant | getProperty(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) Returns the value of the property specified by the dispIdMember.
Parameters: dispIdMember - the ID of the property as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. | public OlePropertyDescription | getPropertyDescription(int index) | public TYPEATTR | getTypeInfoAttributes() | public Variant | invoke(int dispIdMember) Invokes a method on the OLE Object; the method has no parameters. | public Variant | invoke(int dispIdMember, Variant[] rgvarg) Invokes a method on the OLE Object; the method has no optional parameters.
Parameters: dispIdMember - the ID of the method as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. | public Variant | invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) Invokes a method on the OLE Object; the method has optional parameters. | public void | invokeNoReply(int dispIdMember) Invokes a method on the OLE Object; the method has no parameters. | public void | invokeNoReply(int dispIdMember, Variant[] rgvarg) Invokes a method on the OLE Object; the method has no optional parameters. | public void | invokeNoReply(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) Invokes a method on the OLE Object; the method has optional parameters. | public boolean | setProperty(int dispIdMember, Variant rgvarg) Sets the property specified by the dispIdMember to a new value. | public boolean | setProperty(int dispIdMember, Variant[] rgvarg) Sets the property specified by the dispIdMember to a new value.
Parameters: dispIdMember - the ID of the property as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. |
OleAutomation | public OleAutomation(IDispatch idispatch)(Code) | | |
OleAutomation | public OleAutomation(OleClientSite clientSite)(Code) | | Creates an OleAutomation object for the specified client.
Parameters: clientSite - the site for the OLE Document or ActiveX Control whose additional functionality you need to access exception: IllegalArgumentException - - ERROR_INVALID_INTERFACE_ADDRESS when called with an invalid client site
|
dispose | public void dispose()(Code) | | Disposes the automation object.
This method releases the IDispatch interface on the OLE Document or ActiveX Control.
Do not use the OleAutomation object after it has been disposed.
|
getAddress | int getAddress()(Code) | | |
getDocumentation | public String getDocumentation(int dispId)(Code) | | |
getFunctionDescription | public OleFunctionDescription getFunctionDescription(int index)(Code) | | |
getIDsOfNames | public int[] getIDsOfNames(String[] names)(Code) | | Returns the positive integer values (IDs) that are associated with the specified names by the
IDispatch implementor. If you are trying to get the names of the parameters in a method, the first
String in the names array must be the name of the method followed by the names of the parameters.
Parameters: names - an array of names for which you require the identifiers positive integer values that are associated with the specified names in the sameorder as the names where provided; or null if the names are unknown |
getLastError | public String getLastError()(Code) | | Returns a description of the last error encountered.
a description of the last error encountered |
getNames | public String[] getNames(int dispId, int maxSize)(Code) | | |
getProperty | public Variant getProperty(int dispIdMember)(Code) | | Returns the value of the property specified by the dispIdMember.
Parameters: dispIdMember - the ID of the property as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames the value of the property specified by the dispIdMember or null |
getProperty | public Variant getProperty(int dispIdMember, Variant[] rgvarg)(Code) | | Returns the value of the property specified by the dispIdMember.
Parameters: dispIdMember - the ID of the property as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. All arguments are considered to beread only unless the Variant is a By Reference Variant type. the value of the property specified by the dispIdMember or null since: 2.0 |
getProperty | public Variant getProperty(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)(Code) | | Returns the value of the property specified by the dispIdMember.
Parameters: dispIdMember - the ID of the property as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. All arguments are considered to beread only unless the Variant is a By Reference Variant type. Parameters: rgdispidNamedArgs - an array of identifiers for the arguments specified in rgvarg; theparameter IDs must be in the same order as their corresponding values;all arguments must have an identifier - identifiers can be obtained using OleAutomation.getIDsOfNames the value of the property specified by the dispIdMember or null since: 2.0 |
getPropertyDescription | public OlePropertyDescription getPropertyDescription(int index)(Code) | | |
getTypeInfoAttributes | public TYPEATTR getTypeInfoAttributes()(Code) | | |
invoke | public Variant invoke(int dispIdMember)(Code) | | Invokes a method on the OLE Object; the method has no parameters.
Parameters: dispIdMember - the ID of the method as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames the result of the method or null if the method failed to give result information |
invoke | public Variant invoke(int dispIdMember, Variant[] rgvarg)(Code) | | Invokes a method on the OLE Object; the method has no optional parameters.
Parameters: dispIdMember - the ID of the method as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. All arguments are considered to beread only unless the Variant is a By Reference Variant type. the result of the method or null if the method failed to give result information |
invoke | public Variant invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)(Code) | | Invokes a method on the OLE Object; the method has optional parameters. It is not
necessary to specify all the optional parameters, only include the parameters for which
you are providing values.
Parameters: dispIdMember - the ID of the method as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. All arguments are considered to beread only unless the Variant is a By Reference Variant type. Parameters: rgdispidNamedArgs - an array of identifiers for the arguments specified in rgvarg; theparameter IDs must be in the same order as their corresponding values;all arguments must have an identifier - identifiers can be obtained using OleAutomation.getIDsOfNames the result of the method or null if the method failed to give result information |
invokeNoReply | public void invokeNoReply(int dispIdMember)(Code) | | Invokes a method on the OLE Object; the method has no parameters. In the early days of OLE,
the IDispatch interface was not well defined and some applications (mainly Word) did not support
a return value. For these applications, call this method instead of calling
public void invoke(int dispIdMember) .
Parameters: dispIdMember - the ID of the method as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames exception: SWTException - - ERROR_ACTION_NOT_PERFORMED when method invocation fails
|
invokeNoReply | public void invokeNoReply(int dispIdMember, Variant[] rgvarg)(Code) | | Invokes a method on the OLE Object; the method has no optional parameters. In the early days of OLE,
the IDispatch interface was not well defined and some applications (mainly Word) did not support
a return value. For these applications, call this method instead of calling
public void invoke(int dispIdMember, Variant[] rgvarg) .
Parameters: dispIdMember - the ID of the method as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. All arguments are considered to beread only unless the Variant is a By Reference Variant type. exception: SWTException - - ERROR_ACTION_NOT_PERFORMED when method invocation fails
|
invokeNoReply | public void invokeNoReply(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)(Code) | | Invokes a method on the OLE Object; the method has optional parameters. It is not
necessary to specify all the optional parameters, only include the parameters for which
you are providing values. In the early days of OLE, the IDispatch interface was not well
defined and some applications (mainly Word) did not support a return value. For these
applications, call this method instead of calling
public void invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) .
Parameters: dispIdMember - the ID of the method as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. All arguments are considered to beread only unless the Variant is a By Reference Variant type. Parameters: rgdispidNamedArgs - an array of identifiers for the arguments specified in rgvarg; theparameter IDs must be in the same order as their corresponding values;all arguments must have an identifier - identifiers can be obtained using OleAutomation.getIDsOfNames exception: SWTException - - ERROR_ACTION_NOT_PERFORMED when method invocation fails
|
setProperty | public boolean setProperty(int dispIdMember, Variant rgvarg)(Code) | | Sets the property specified by the dispIdMember to a new value.
Parameters: dispIdMember - the ID of the property as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - the new value of the property true if the operation was successful |
setProperty | public boolean setProperty(int dispIdMember, Variant[] rgvarg)(Code) | | Sets the property specified by the dispIdMember to a new value.
Parameters: dispIdMember - the ID of the property as specified by the IDL of the ActiveX Control; thevalue for the ID can be obtained using OleAutomation.getIDsOfNames Parameters: rgvarg - an array of arguments for the method. All arguments are considered to beread only unless the Variant is a By Reference Variant type. true if the operation was successful since: 2.0 |
|
|