JNA 问题
我现在用Java调用dll文件,但是我不知道c下面对应的参数const WCHAR* ,在java中怎么用:
dll借口描述:
BOOL WriteProfileStr(const WCHAR* sSection,const WCHAR* sEntry,const WCHAR* sValue,const WCHAR* sIniPath)
参数类型改为宽字符串
我java该怎么写?
我写了个好像工作不正常:
public class HelloWorld {
// This is the standard, stable way of mapping, which supports extensive
// customization and mapping of Java to native types.
// BOOL WriteProfileStr(const WCHAR* sSection,const WCHAR* sEntry,const WCHAR* sValue,const WCHAR* sIniPath)
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary)
Native.loadLibrary((Platform.isWindows() ? "c:/forunicode" : "c"),
CLibrary.class);
void printf(String format, Object... args);
public boolean WriteProfileStr(String sSection,String sEntry,String sValue,String sIniPath);
}
public static void main(String[] args) {
// CLibrary.INSTANCE.printf("Hello, World\n");
boolean f = CLibrary.INSTANCE.WriteProfileStr("news", "", "", "C:/newstest.ini");
System.out.println(f);
for (int i=0;i < args.length;i++) {
CLibrary.INSTANCE.printf("Argument %d: %s\n", i, args[i]);
}
}
}