Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Setting the time on a Windows machine

by dree (Monsignor)
on Jul 08, 2002 at 13:16 UTC ( #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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://180167]
[Corion]: Hi marto ;)
[Discipulus]: Corion ah! you opened a new search path! thanks
[choroba]: LanX No, but they grow and want more!
LanX was conditioned by a female
Discipulus my 'kids' always complain with our car..
[LanX]: true, cars are bad in growing
[marto]: WaitWindow()
[Corion]: Discipulus: You need to respond with 0 to WM_QUERYENDSESSION
[Discipulus]: why win must be SO complicated!?!? maybe i'll ask a SoPW

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2017-01-17 09:52 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (154 votes). Check out past polls.