note 39181 deleted from ref.w32api by sobak
| From: | sobak@php.net | Date: | Tue, 22 Nov 2016 03:50:43 +0000 |
| Subject: | note 39181 deleted from ref.w32api by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207456@lists.php.net to get a copy of this message | ||
Note Submitter: Philip Soeberg
----
In response to post by Jan Kleinsorge.
To get the proper windows system uptime, one should use the Performance Monitoring system...
GetTickCount is limited to 49.7 days, as the result is a dword.
<?php
if (!dl("php_w32api.dll")) {
echo "Unable to load php_w32api.dll";
exit;
}
$api = new win32;
$api->registerfunction("bool QueryPerformanceCounter (float &lpPerformanceCount) From
kernel32.dll");
$api->registerfunction("bool QueryPerformanceFrequency (float &lpPerformanceFrequency)
From kernel32.dll");
$api->QueryPerformanceCounter($a);
$api->QueryPerformanceFrequency($b);
$c = $a/$b;
$days = floor($c / 86400);
echo gmstrftime("System uptime is $days Days, %H Hr, %M Min, %S Sec<br>", $c);
?>
The above snippet will return the true uptime for an unlimited time for a windows OS. (Disregarding
the fact that windows needs reboot every 10 days or so :))
A tiny dange though is the lack of 64bit variable types in php.. (the "float
&lpPerformanceCount" should be "long long &lpPerformanceCount") ..
Nevertheless.. It works :)
Philip S.