gpt4 book ai didi

java - JNA 中 SHChangeNotify 的正确映射

转载 作者:太空宇宙 更新时间:2023-11-04 08:26:48 25 4
gpt4 key购买 nike

这是来自 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);

}

我遇到以下异常:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'SHChangeNotify'

知道如何正确书写吗?

最佳答案

不是从 com.sun.jna.platform.win32.Shell32 扩展 Shell32 接口(interface),而是从 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
}

关于java - JNA 中 SHChangeNotify 的正确映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8339275/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com