note 39181 added to ref.w32api
| From: | PhilipSoeberg at rn2 dot php dot net | Date: | Tue, 20 Jan 2004 01:09:36 +0000 |
| Subject: | note 39181 added to ref.w32api | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-63853@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/ref.w32api.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39181
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39181&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39181&report=yes
Search -- http://master.php.net/manage/user-notes.php