这是我的代码。我输入了JNA外部jar文件,但由于我收到“SPI INSTANCE =(SPI)Native.loadLibrary(”user32“,SPI.class,new HashMap(){”)错误,因此无法编译该错误。错误是: “在类型本地的方法调用LoadLibrary(字符串,类,地图)是不适用的参数(字符串,类,新的HashMap(){})”如何纠正Native.loadlibrary错误
package desktop;
import java.util.HashMap;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.WinDef.UINT_PTR;
import com.sun.jna.win32.*;
public class WallpaperChanger {
public static void main(String[] args) {
//supply your own path instead of using this one
String path = "D:\\stone.png";
SPI.INSTANCE.SystemParametersInfo(
new UINT_PTR(SPI.SPI_SETDESKWALLPAPER),
new UINT_PTR(0),
path,
new UINT_PTR(SPI.SPIF_UPDATEINIFILE | SPI.SPIF_SENDWININICHANGE));
}
public interface SPI extends StdCallLibrary {
//from MSDN article
long SPI_SETDESKWALLPAPER = 20;
long SPIF_UPDATEINIFILE = 0x01;
long SPIF_SENDWININICHANGE = 0x02;
@SuppressWarnings("serial")
//This is where the error starts:
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
);
}
}
在型本机的方法的LoadLibrary(字符串,类,地图)不适用于 更新参数(,新的HashMap <对象,对象>(){}字符串,班)错误信息。这是我打算输入的内容。我对任何混淆抱歉。 –
Corbin