News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Synchronizate PC time

Started by six_L, February 20, 2006, 01:13:54 PM

Previous topic - Next topic

GregL

Here is another way to get the current offset from UTC (in minutes):


CurrentUtcOffsetInMinutes PROC

    ; Returns: eax = the current offset from UTC in minutes
    ; Example: returns -480 for Pacific Standard Time
    ;          returns -420 for Pacific Daylight Time 
    ; Gets the value from the Windows Registry at
    ;  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias         
   
    LOCAL hKey:DWORD
    LOCAL dwType:DWORD
    LOCAL sdwData:SDWORD
    LOCAL cbData:DWORD
   
    mov cbData, SIZEOF sdwData
    INVOKE RegOpenKeyEx, HKEY_LOCAL_MACHINE, SADD("SYSTEM\CurrentControlSet\Control\TimeZoneInformation"), 0, KEY_QUERY_VALUE, ADDR hKey
    INVOKE RegQueryValueEx, hKey, SADD("ActiveTimeBias"), NULL, ADDR dwType, ADDR sdwData, ADDR cbData
    INVOKE RegCloseKey, hKey
    mov eax, sdwData
    neg eax
    ret
   
CurrentUtcOffsetInMinutes ENDP


herge

Hi dsouza123:

It does work, but it is adjusting the time to Greenwich[London] [GMT] [UTC] which
is four hours ahead. I used the httpsync7.zip
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

dsouza123

The program works by combining the GMT offset setting in the computer
(which it gets using  GetTimeZoneInformation
and displays both the hour and minutes in editable fields
so you can change them, maybe you like to set your clock ahead),

along with the values converted from the text from the HEAD reply

example
GMT offset -4 00 
Date: Tue, 03 Jul 2007 23:42:44 GMT

will combine for 19:42:44 or 7:42:44 PM