急用,在线急等。网上这方面例子太少

解决方案 »

  1.   

    JNA只能用于Java调用C的方法
    JNI可以相互调用。
    所以,你可以用JNI,到网上搜JNI调用Java方法,会搜到一大堆资料
      

  2.   


    /**
     * @company suteam
     * @author masj
     * @since Aug 2, 2010
     * @version 1.0
     */
    @SuppressWarnings("deprecation")
    public class SwapToClientManagerImpl implements SwapToClientManager { private static final Log logger = LogFactory.getLog(SwapToClientManagerImpl.class); static JNative myjnative = null;

    private static String path = ""; public boolean addControl(String filename, String password, String serverIP)
    throws MessageException {
    try {
    if (myjnative == null) {
    myjnative = new JNative(path+"objctrl.dll", "AddControl");
    myjnative.setRetVal(Type.INT);
    }
    int i = 0;
    myjnative.setParameter(i++, filename);
    myjnative.setParameter(i++, password);
    myjnative.setParameter(i++, serverIP); myjnative.invoke();
    int result = myjnative.getRetValAsInt(); if (result == 1)
    return true;
    } catch (Exception e) {
    logger.error("...", e);
    throw new MessageException("....");
    } finally {
    if (myjnative != null) {
    try {
    myjnative.dispose();
    } catch (Exception e) {
    }
    }
    } return false;
    }
    }