C# 确定系统是否正在对其时间时钟进行定期时间调整,并获取任何此类调整的值和周期。
官网链接:https://docs.microsoft.com/zh-cn/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeadjustment
使用:
[DllImport("Kernel32.dll", SetLastError = true)]
public static extern int GetSystemTimeAdjustment(ref int IpTimeAdjustment, ref int IpTimeIncremnet, ref bool IpTimeAdjustDisabled);
public static int GetSysIn()
{
IpTimeAdjustment = 0;
int IpTimeIncremnet = 0;
bool IpTimeAdjustDisabled = false;
// IpTimeAdjustDisabled 为true, 是手动修改了时间.为false, 是自动设置时间。
int res = ClassA.GetSystemTimeAdjustment(ref IpTimeAdjustment, ref IpTimeIncremnet, ref IpTimeAdjustDisabled);
return res;
}
注意:这个方法有问题。
系统:win10 64位
问题描述: 在使用该函数判断系统时间 【自动设置时间】 【开】时,第一次进行判断,都需要更在下面的状态,该函数才返回正确。
否则,获取结果总是false .....
该问题有待解决!!!!!!!
修改系统时间参考:
https://blog.csdn.net/nihang1234/article/details/69945290