我正在ITLSSPProc.dll
使用具有功能的 JNI 调用函数OpenSSPComPort(Pointer param);
该指针 ref 指向内存中的波特率和 端口号,这是我尝试过但无法打开端口的代码。
public class Main {
public interface ITLSSPProc extends Library {
ITLSSPProc INSTANCE = (ITLSSPProc)
Native.loadLibrary((Platform.isWindows()
? "ITLSSPProc"
: "simpleDLLWindowsPort"),
ITLSSPProc.class);
int OpenSSPComPort(Pointer param);
int CloseSSPComPort(Pointer param);
}
public static void main(String[] args)throws IOException {
ITLSSPProc sdll = ITLSSPProc.INSTANCE;
Memory intMem = new Memory(10); // allocating space
intMem.setLong(0,9600);
intMem.setString(1,"com7");
Pointer intPointer = intMem.getPointer(0);
if(sdll.OpenSSPComPort(intMem)==1)
{
System.out.println("connected");
}
else
{
}
}
}