有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

DLL JAVA调用嵌套DLL方法

我有一个DLL,但没有它的源代码。我想在这个DLL中调用一个方法。 DLL that is ActiveX

现在在这张照片里。您可以看到我想要访问的是Test2.DLL,它有fb1_CheckSensor方法。但是它驻留在Test1中。动态链接库

假设我只有一个选择,那就是加载一个DLL。只有Test1。JAVA的动态链接库

    import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;

public interface FB4API3Lib extends Library{

FB4API3Lib INSTANCE = (FB4API3Lib)Native.loadLibrary("Interop.FB4API3Lib.dll", FB4API3Lib.class);


int fb1_Open(int nUnit);
void fb1_Close(int nUnit);
void fb1_SetCommunicationMode(int nMode);
int fb1_GetNumberOfUnits();
NativeLong fb1_Stop(int nUnit);
int fb1_Reset(int nUnit);
int fb1_CheckSensor(int nUnit,StringByReference strWrk);
int fb1_SetImageFileFolder(int nUnit,String strPath);
int fb1_SetImageFileName(int nUnit,String strFileName);
int fb1_SetImageRegulation(int nUnit,tagImageInfo pImageInto);
NativeLong fb1_SetEndorseData(int nUnit,String strEds);
NativeLong fb1_SetEndorseMultiLine (int nUnitNo, tagEdsMulti  pInfo);
int fb1_Run(int nUnit, IntByReference strWrk3, StringByReference strWrk, IntByReference strWrk2);
int fb1_Run1(int nUnit,StringByReference strWrk,IntByReference strWrk2);
int fb1_Run1Ex(int nUnit,StringByReference strWrk,IntByReference strWrk2);
int fb1_Eject(int nUnit,int nPocket,int nNext);
int fb1_WaitEjecting(int nUnit);
int fb1_WaitCompleted(int nUnit);
void fb1_GetDetailErrorInfo(String strErr);
int fb1_Initialize(int nUnit);
int fb1_SetBinaryMode(int nUnit, int nSide, int nMode);
int fb1_SetRunMode(int nUnit, int nMOde, int nOpt, int nPkt);
int fb1_GetImageData(int nUnit, PointerByReference hBmap);
int fb1_GetEndorseStatus(int nUnit, IntByReference pType, int nFunc, tagMtrIjpSts pStutus);
int fb1_SetDeviceInfo(int nUnit, int nDeviceInfoID, String pszIn);
int fb1_SetBinaryInfo(int nUnit, int nSide, tagFb1BiInfo pBiInfo);

}

现在来看实现上述接口的类

   import com.sun.jna.NativeLong;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;


public class CallDLL implements FB4API3Lib {

    public int fb1_Open(int nUnit) {
    return INSTANCE.fb1_Open(nUnit);
}

public Object CreateTheClass() {
    return INSTANCE;
}

public void fb1_Close(int nUnit) {
    INSTANCE.fb1_Close(nUnit);
}
public void fb1_SetCommunicationMode(int nMode) {
    INSTANCE.fb1_SetCommunicationMode(nMode);
}

public int fb1_GetNumberOfUnits() {
    return INSTANCE.fb1_GetNumberOfUnits();
}

public NativeLong fb1_Stop(int nUnit) {
    return INSTANCE.fb1_Stop(nUnit);
}

public int fb1_Reset(int nUnit) {
    return INSTANCE.fb1_Reset(nUnit);
}

public int fb1_CheckSensor(int nUnit,StringByReference strWrk) {
    return INSTANCE.fb1_CheckSensor(nUnit,strWrk);
}

public int fb1_SetImageFileFolder(int nUnit,String strPath) {
    return INSTANCE.fb1_SetImageFileFolder(nUnit,strPath);
}

public int fb1_SetImageFileName(int nUnit,String strFileName) {
    return INSTANCE.fb1_SetImageFileName(nUnit,strFileName);
}

public int fb1_SetImageRegulation(int nUnit,tagImageInfo pImageInto) {
    return INSTANCE.fb1_SetImageRegulation(nUnit,pImageInto);
}

public NativeLong fb1_SetEndorseMultiLine(int nUnit,tagEdsMulti pInfo) {
    return INSTANCE.fb1_SetEndorseMultiLine(nUnit,pInfo);
}

public NativeLong fb1_SetEndorseData(int nUnit,String strEds) {
    return INSTANCE.fb1_SetEndorseData(nUnit,strEds);
}

public int fb1_Run(int uUnit, IntByReference strWrk3, StringByReference strWrk, IntByReference len) {
    return INSTANCE.fb1_Run(uUnit, strWrk3, strWrk, len);
}
public int fb1_Run1(int nUnit,StringByReference strWrk,IntByReference len) {
    return INSTANCE.fb1_Run1(nUnit,strWrk, len);
}

public int fb1_Run1Ex(int nUnit,StringByReference strWrk,IntByReference len) {
    return INSTANCE.fb1_Run1Ex(nUnit,strWrk, len);
}

public int fb1_Eject(int nUnit,int nPocket, int nNext) {
    return INSTANCE.fb1_Eject(nUnit,nPocket, nNext);
}

public int fb1_WaitEjecting(int nUnit) {
    return INSTANCE.fb1_WaitEjecting(nUnit);
}

public int fb1_WaitCompleted(int nUnit) {
    return INSTANCE.fb1_WaitCompleted(nUnit);
}

public void fb1_GetDetailErrorInfo(String strWrk) {
    INSTANCE.fb1_GetDetailErrorInfo(strWrk);
}

public int fb1_Initialize(int nUnit){
    return INSTANCE.fb1_Initialize(nUnit);
}

public int fb1_SetBinaryMode(int nUnit, int nSide, int nMode){
    return INSTANCE.fb1_SetBinaryMode(nUnit, nSide, nMode);
}

public int fb1_SetRunMode(int nUnit, int nMode, int nOpt, int nPkt){
    return INSTANCE.fb1_SetRunMode(nUnit, nMode, nOpt, nPkt);
}

public int fb1_GetImageData(int nUnit, PointerByReference pBmap){
    return INSTANCE.fb1_GetImageData(nUnit, pBmap);
}

public int fb1_GetEndorseStatus(int nUnit, IntByReference pType, int nFunc, tagMtrIjpSts pStutus){
    return INSTANCE.fb1_GetEndorseStatus(nUnit, pType, nFunc, pStutus);
}

public int fb1_SetDeviceInfo(int nUnit, int nDeviceInfoID, String pszIn){
    return INSTANCE.fb1_SetDeviceInfo(nUnit, nDeviceInfoID, pszIn);
}

public int fb1_SetBinaryInfo(int nUnit, int nSide, tagFb1BiInfo pBiInfo){
    return INSTANCE.fb1_SetBinaryInfo(nUnit, nSide, pBiInfo);
}

}

所以这里的问题是。我很抱歉,我将无法达到测试2。DLL,因为我实际尝试调用接口的地方是Test1。动态链接库

我只能加载Test1。DLL和tere是我无法加载Test2的。DLL作为另一个实例。 我怎样才能达到测试2。DLL只需加载Test1。DLL作为父级


共 (0) 个答案