这是来自MSDN的SHChangeNotify函数的语法:
void SHChangeNotify(
LONG wEventId,
UINT uFlags,
__in_opt LPCVOID dwItem1,
__in_opt LPCVOID dwItem2
);
我要在Java Native Access [JNA]中编写Java对应物,但这个声明似乎是错误的:
public interface Shell32 extends com.sun.jna.platform.win32.Shell32 {
public Shell32 INSTANCE = (Shell32) Native.loadLibrary(Shell32.class);
void SHChangeNotify(long wEventId, int uFlags, Pointer dwItem1, Pointer dwItem2);
}
我遇到以下异常:
线程“main”中的异常java.lang.UnsatisfiedLinkError:错误 查找功能'SHChangeNotify'
知道怎么写得正确吗?
答案 0 :(得分:1)
不是从com.sun.jna.platform.win32.Shell32
扩展Shell32接口,而是从StdCallLibrary
public interface Shell32 extends StdCallLibrary {
final static Map<String, Object> WIN32API_OPTIONS = new HashMap<String, Object>() {
private static final long serialVersionUID = 1L;
{
put(Library.OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
put(Library.OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
}
};
public Shell32 INSTANCE = (Shell32) Native.loadLibrary("Shell32", Shell32.class, WIN32API_OPTIONS);
//whatever you want to expose here
}