如何在AIX中获得绝对增加的计数 [英] How to get absolutely increasing count in AIX

查看:78
本文介绍了如何在AIX中获得绝对增加的计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好〜

我正在寻找如何在AIX中获得绝对增加的数量。



有人帮我。 T_T



我的尝试:



我不想要以下情况。



Hello~
i'm finding how to get absolutely increasing count in AIX.

somebody help me. T_T

What I have tried:

I do not want the following cases.

...
FILE *utmp = fopen(UTMP_FILE, "r");

   if (utmp == NULL) {
     /* Can't open utmp, use current time as boottime */
     boottime = time(NULL);
   } else {
     while (fread((char *) &buf, sizeof(buf), 1, utmp) == 1) {
        if (buf.ut_type == BOOT_TIME) {
            boottime = buf.ut_time;
            break;
        }
     }
   }
...





因为如果系统时间使用诸如date之类的命令更改

获得了错误的值。



because if the system time is changed using a command such as "date"
the wrong value is obtained.

推荐答案

如果您正在寻找单调时钟使用单调时钟: IBM知识中心 - clock_getres,clock_gettime和clock_settime子例程 [ ^ ]。
If you are looking for a monotonic clock the do use a monotonic clock: IBM Knowledge Center - clock_getres, clock_gettime, and clock_settime Subroutine[^].


差不多,你不能。想一想:暂时忽略电脑。

你坐在车里,手机在家里,你不戴手表。

几点了它?

你的车上有时钟 - 但是这样吗?你是否为夏令时调整了它?你有正确的方式调整吗?

你不能说,除非你使用一些可靠的外部时间源 - 在这种情况下,你可以打开收音机并找到一个会告诉你的电台。然后,您可以根据您的车时钟检查,并确定它是否正确。但是如果广播坏了吗?你只有时钟继续,你根本不能告诉它是否正确。



回到你的问题,你有同样的事情:除非你有权访问对于互联网和外部时间源,您只能使用系统时钟,并且可以随意更改(因为Windows无法访问外部时钟,除非它已连接到互联网!)



猜测,你试图阻止用户倒退时间并保持在试用期 - 但是你可以做的唯一事情是记录最后的日期和时间。应用程序运行的时间,并将系统时间与尝试发现欺骗行为的时间进行比较。除非您可以访问外部时间源,否则您无法做其他事情......
Pretty much, you can't. Think about it: ignore computers for a moment.
You are sat in your car, your mobile is at home, you don't wear a watch.
What time is it?
You have the clock in your car - but is that right? did you adjust it for daylight savings time? Did you adjust it the right way?
You can't tell, unless you use some reliable external time source - in this case, you can turn on the radio and find a station that will tell you. You can then check that against your car clock and decide if it's right or not. But if the radio is broken? You have only the clock to go on and you cannot tell at all if it's right.

Back to your problem, and you have the same thing: unless you have access to the internet and an external time source, you have only got the system clock to work with and that can be changed at will (because Windows can't access an external clock unless it's connected to the internet!)

At a guess, you are trying to prevent users from "rewinding time" and staying inside a "trial period" - but about the only thing you can do it record the last date & time at which your app was running, and compare the system time to that to try and spot teh cheats. Unless you have access to external time sources, you can't do much else...


这篇关于如何在AIX中获得绝对增加的计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆