我正在尝试获取有关 Windows 在进入空闲状态后关闭笔记本电脑屏幕的时间的信息。
我尝试了以下代码,但我对 jna 的经验很少,并且结构结果始终为 0:
WinNT.SYSTEM_POWER_POLICY systemPowerPolicy= new WinNT.SYSTEM_POWER_POLICY();
Pointer pointer=systemPowerPolicy.getPointer();
PowrProf.INSTANCE.CallNtPowerInformation(PowrProf.POWER_INFORMATION_LEVEL.SystemPowerPolicyCurrent,
Pointer.NULL,0, pointer, systemPowerPolicy.size());
System.out.println(systemPowerPolicy.VideoDimDisplay);
System.out.println(systemPowerPolicy.VideoTimeout);
我相信我没有正确调用该函数,你能帮忙调用这个函数吗?
问候
int size = new WinNT.SYSTEM_POWER_POLICY().size();
Memory mem = new Memory(size);
PowrProf.INSTANCE
.CallNtPowerInformation(PowrProf.POWER_INFORMATION_LEVEL.SystemPowerPolicyCurrent, null, 0, mem, size);
WinNT.SYSTEM_POWER_POLICY powerPolicy = new WinNT.SYSTEM_POWER_POLICY(mem);
System.out.println(powerPolicy.VideoTimeout);