in reply to Setting the time on a Windows machine
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" }
|
|---|