import com.ms.com.*; import com.ms.wfc.ui.*; /** * This class is used to create automation objects instead of * ActiveXComponent - this creates them on the current thread * instead of the VM's STA thread */ public class COMAutomation { private static final _Guid IID_IUnknown = new _Guid( "{00000000-0000-0000-C000-000000000046}"); public static Object createObject(String str) { try { return com.ms.win32.Ole32.CoCreateInstance( com.ms.win32.Ole32.CLSIDFromProgID(str), null, ComContext.INPROC_SERVER | com.ms.win32.win.CLSCTX_LOCAL_SERVER, IID_IUnknown); } catch (Exception e) { MessageBox.show("Can't create COM component:"+str); return null; } } public static void release(Object o) { try { if (o != null) com.ms.com.ComLib.release(o); } catch (Exception e) {} } }