有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java SetWindowDisplayAffinity失败,错误为“拒绝访问”

我正在使用jna。额外的使用java中的User32Extra库查找窗口并更改windowdisplayaffinity值。 但它会返回“拒绝访问”错误代码

HWND top= target.findWindow("WindowTitle");
System.err.println(User32Extra.INSTANCE.SetWindowDisplayAffinity(top, 0));
System.err.println(Native.getLastError());

以下代码给出“false”和错误代码“5”(访问被拒绝)

我需要额外的权限吗?这一错误的原因是什么


共 (1) 个答案

  1. # 1 楼答案

    SetWindowDisplayAffinity只能在调用进程拥有的窗口上使用。因此出现了错误。文件上说:

    This feature enables applications to protect their own onscreen window content from being captured or copied through a specific set of public operating system features and APIs.

    如果另一个应用程序可以如此轻易地覆盖目标应用程序的选择,该功能将变得无用