[英]JNA loadLibrary() method shows an error with arguments
I want to set image as a desktop wallpaper using Java.我想使用 Java 将图像设置为桌面墙纸。 I found a solution in the internet but it does not work.
我在互联网上找到了一个解决方案,但它不起作用。 I can't understand what is wrong with it.
我无法理解它有什么问题。
Here is what it says to me?这是它对我说的? Can you help me?
你能帮助我吗?
import com.sun.jna.Native;
import com.sun.jna.platform.win32.WinDef.UINT_PTR;
import com.sun.jna.win32.*;
import java.util.HashMap;
public class WallpaperSetter {
public interface SPI extends StdCallLibrary {
//from MSDN article
long SPI_SETDESKWALLPAPER = 20;
long SPIF_UPDATEINIFILE = 0x01;
long SPIF_SENDWININICHANGE = 0x02;
//Here is the problem
SPI INSTANCE = (SPI) Native.loadLibrary("user32", SPI.class, new HashMap<Object, Object>() {
{
put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
}
});
boolean SystemParametersInfo(
UINT_PTR uiAction,
UINT_PTR uiParam,
String pvParam,
UINT_PTR fWinIni
);
}
public static void setWallpaper(String image_url) {
String path = image_url;
SPI.INSTANCE.SystemParametersInfo(
new UINT_PTR(SPI.SPI_SETDESKWALLPAPER),
new UINT_PTR(0),
path,
new UINT_PTR(SPI.SPIF_UPDATEINIFILE | SPI.SPIF_SENDWININICHANGE));
}
}
Ok.好的。 All is needed to change
Map<Object, Object>
to Map<String, Object>
只需要将
Map<Object, Object>
更改为Map<String, Object>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.