Call COM object

From CodeCodex

Revision as of 07:08, 18 August 2009 by Techmind (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Implementations

Java

com4j A Java library that allows Java applications to seemlessly interoperate with Microsoft Component Object Model. First generate Java type definitions from a COM type library. Here we are doing for the type library for the Windows Scripting Host.

<highlightsyntax language="java122"> > java -jar tlbimp.jar -o wsh -p test.wsh %WINDIR%\system32\wshom.ocx

</highlightsyntax> Then we are able to call WSH objects/methods. <highlightsyntax language="java122"> public class Main {

 public static void main(String[] args) {
   IFileSystem3 fs = ClassFactory.createFileSystemObject();
   for( String file : args )
     System.out.println(fs.getFileVersion(file));
 }

}

</highlightsyntax> https://com4j.dev.java.net/

j-interop Implementation of DCOM wire protocol (MSRPC) to enable development of Pure Bi-Directional, Non-Native Java applications which can interoperate with any COM component. The implementation is itself purely in Java and does not use JNI to provide COM access. http://sourceforge.net/projects/j-interop

j-xchange Pure java implementation of the entire Collaboration Data Objects (CDO 1.21) library for accessing Microsoft Exchange Server in a platform independent manner. http://sourceforge.net/projects/j-xchange/



See also this HowTo for an alternative package to access a COM package from Java.