Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Setting the time on a Windows machine

by dree (Monsignor)
on Jul 08, 2002 at 13:16 UTC ( [id://180167]=note: print w/replies, xml ) Need Help??


in reply to Setting the time on a Windows machine

This code works for me: it sets new time for my Win98 box.
use strict; use Win32::API; my $GetSystemTime = new Win32::API('kernel32', 'GetSystemTime', 'P', ' +V'); #you can also use GetLocalTime my $lpSystemtime = pack('S8',0,0,0,0,0,0,0,0); $GetSystemTime->Call($lpSystemtime); my ($wYear,$wMonth,$wDayOfWeek,$wDay,$wHour,$wMinute,$wSecond,$wMillis +econds) = unpack('S8', $lpSystemtime); print "Actual time is: $wHour:$wMinute:$wSecond\n"; $wHour++; $wMinute++; $wSecond++; $lpSystemtime = pack('S8',$wYear,$wMonth,$wDayOfWeek,$wDay,$wHour,$wMi +nute,$wSecond,$wMilliseconds); my $SetSystemTime = new Win32::API('kernel32', 'SetSystemTime', 'P', ' +I'); #you can also use SetLocalTime if ($SetSystemTime->Call($lpSystemtime)) { print "The new time is correctly setted: $wHour:$wMinute:$wSecond\ +n" } else { print "Error setting the time\n" }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://180167]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-25 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found