Jana 使用的 Sabjidl 位置

ShObjIdl location for JNA usage

我正在尝试使用 shobjidl_core.h 库来 运行 代码来更改一个特定显示器的壁纸,具体来说我需要 运行 这两个函数:GetMonitorDevicePathAt, SetWallpaper.

现在,当我运行以下代码时:

    interface shobjidl_core extends Library {
        test.shobjidl_core INSTANCE = Native.load( "shobjidl_core", shobjidl_core.class);

        void GetMonitorDevicePathAt(int monitorIndex, WString m);
        void SetWallpaper(WString monitorId, WString wallpaperPath);
    }

我收到一条错误消息 "Unable to load library 'shobjidl'"

我试过“shobjidl”的任何变体,但仍然找不到有效的变体。根据我对 JNA 的了解,它需要一个包含库的 dll,但我找不到与 shobjidl

相关的任何 dll

加载shobjidl应该怎么做?

shobjidl 是一个 C/C++ header 文件,它不是 Windows 附带的库。在 header 中声明的函数通常以 shell32.dll 或 shcore.dll 结束,但在这种情况下你实际上是在谈论 IDesktopWallpaper 而这是一个 COM object .

使用 JNA 或 JNI 或您喜欢的任何 COM 交互方法。

可以找到一个最小的 C++ 示例 here

我在 JNA google 小组得到了帮助。解决我问题的答案可见here. If you want to see a use case example on how to do this you can check it on github