Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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" }


Comment on Re: Setting the time on a Windows machine
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (20)
As of 2014-09-16 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (26 votes), past polls