有关于JCOM组件的问题
最近在学习用Java调用COM组件的事情,在论坛上找到某大虾的帖子:
http://topic.csdn.net/u/20090516/15/f21ec850-bc4c-4ab4-bb1c-bc9b95769395.html
我也根据他的例子做了,但是貌似有问题,贴上代码
import jp.ne.so_net.ga2.no_ji.jcom.IDispatch;import jp.ne.so_net.ga2.no_ji.jcom.ReleaseManager;public class CallDll { public static void main(String[] args) { Process(); } public static String Process() { ReleaseManager rm = new ReleaseManager(); try { IDispatch vbcom = new IDispatch(rm, "U8Distribute.iDistribute"); Object[] param = new Object[] { "XXXXX" }; String strRet = (String) vbcom.method("Process", param); System.out.println("return: " + strRet); } catch (Exception e) { e.printStackTrace(); } finally { rm.release(); } return null; }}jp.ne.so_net.ga2.no_ji.jcom.JComException: createInstance() failed HRESULT=0x800401F3L at jp.ne.so_net.ga2.no_ji.jcom.IDispatch._create(Native Method) at jp.ne.so_net.ga2.no_ji.jcom.IDispatch.create(IDispatch.java:84) at jp.ne.so_net.ga2.no_ji.jcom.IDispatch.<init>(IDispatch.java:46) at com.dcec.call.dll.CallDll.Process(CallDll.java:14) at com.dcec.call.dll.CallDll.main(CallDll.java:8)
ReleaseManager rm = new ReleaseManager(); String res = null; try { IDispatch vbcom; vbcom = new IDispatch(rm, "U8Distribute.iDistribute"); Object[] param = new Object[] { *** }; res = (String) vbcom.method("Process", param); } catch (JComException e) { e.printStackTrace(); throw new Exception("Jcom调用发生异常" + e.getMessage()); } finally { rm.release(); } return res;