Don't know about the APIs; far simpler to just use one of the available
net time service daemons. Why isn't that satisfactory?
--
See this VB6 sample:
http://vbnet.mvps.org/code/network/winsocksynctime.htm
Or use this free alternative:
http://www.gregorybraun.com/WebTime.html
Here's some info you might find useful...
http://tf.nist.gov/service/its.htm
LFS
"mayayana" wrote:
> .
>
>Or use this free alternative:
>
>http://www.gregorybraun.com/WebTime.html
As for me, I just changed the update interval to sync every 6 hours instead of
once a week, so I don't need to run anything to make sure my clock is
synchronize more often than once a week.
Here's a copy of my registry entry. Just copy the next lines and save it as a
file called timeupdate.reg and run it once. It'll reset the update to 6-hour
intervals. Of course you can also modify the "Special Poll Interval" to a
lower or higher number to adjust the update interval.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\Nt
pClient]
"Enabled"=dword:00000001
"InputProvider"=dword:00000001
"AllowNonstandardModeCombinations"=dword:00000001
"CrossSiteSyncFlags"=dword:00000002
"ResolvePeerBackoffMinutes"=dword:0000000f
"ResolvePeerBackoffMaxTimes"=dword:00000007
"CompatibilityFlags"=dword:80000000
"EventLogFlags"=dword:00000000
"DllName"="C:\\WINDOWS\\system32\\w32time.dll"
"SpecialPollTimeRemaining"=hex(7):74,00,69,00,6d,00,65,00,2e,00,6e,00,69,00,73,
\
00,74,00,2e,00,67,00,6f,00,76,00,2c,00,30,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00
"SpecialPollInterval"=dword:00005460
"Nobody" wrote:
> .
>
I use WebTime because it keeps a log which I can analyze later. I can run it
using Task Scheduler and use /auto switch. I lose one second every day on my
Gigabyte motherboard, which is 1 to 2 years old. I am using XP+SP2. I don't
think that computer clocks are that inaccurate, but something else is going
on.
All active sources return the same code.
it is then decoded incorrectly.
The calculation returns the year 1919
UTC 11/21/1919 12:07:50 AM GMT
PC 11/21/2009 4:07:49 PM PST
Close but no cigar.
NTPTime = Asc(Left$(sTime, 1)) * (256 ^ 3) + Asc(Mid$(sTime, 2, 1))
* (256 ^ 2) + Asc(Mid$(sTime, 3, 1)) * (256 ^ 1) + Asc(Right$(sTime, 1))
'and create a valid date based on
'the seconds since January 1, 1990
dwSecondsSince1990 = NTPTime - 2840140800#
UTCDATE = DateAdd("s", CDbl(dwSecondsSince1990), 1 / 1 / 1990)
'fill a SYSTEMTIME structure with the appropriate values
With ST
.wYear = Year(UTCDATE)
.wMonth = Month(UTCDATE)
.wDay = Day(UTCDATE)
.wHour = Hour(UTCDATE)
.wMinute = Minute(UTCDATE)
.wSecond = Second(UTCDATE)
End With
"Nobody" wrote:
> .
>
"Bee" <B...@discussions.microsoft.com> wrote
> The site sighted has an error in the calculation.
> http://vbnet.mvps.org/code/network/winsocksynctime.htm
> UTCDATE = DateAdd("s", CDbl(dwSecondsSince1990), 1 / 1 / 1990)
Be sure to include the # for dates:
> UTCDATE = DateAdd("s", CDbl(dwSecondsSince1990), #1 / 1 / 1990#)
What you show equates to a couple of divisions:
1 / 1 / 1990 = 5.025126E-04
Thats not the number you want! Its supposed to be 32874.
LFS
"Larry Serflaten" wrote:
> .
>
[....]motherboard, which is 1 to 2 years old. I am using XP+SP2. I don't
>think that computer clocks are that inaccurate, but something else is going
>on.
You're using too many CPU cycles.
There are two clocks we're talking about here, the RTC or realtime clock, the
battery-operated clock on a chip on the mother board and the system clock, the
software clock that operates on CPU cycles as your computer runs.
The clock you see and use in programs is the system clock. It is likely to be
inaccurate unless reset often because as the CPU bogs down the system clock
may not be updated as often. Sometimes the system clock is set to advance a
little to make up for the CPU losses, which means that if you are running a
computer with very little load, the system clock may run faster than real
time.
I'd bet that if you turned off your computer when your time is really
inaccurate and then rebooted, you'd find that the time was fairly accurate
once again. That's because the system clock polls the RTC during bootup.
Most clock-setting software including Windows' own resets both the RTC and the
system clocks.
Again, I find that changing the registry value for the time setting interval
is a no muss no fuss way to keep the clocks accurate.
> As for me, I just changed the update interval to sync every 6 hours
> instead of
> once a week, so I don't need to run anything to make sure my clock is
> synchronize more often than once a week.
Can you explain that sentence to me? It sounds like you totally contradicted
yourself.
>Can you explain that sentence to me? It sounds like you totally contradicted
>yourself.
I thought it was fairly clear. Left to its own devices, Windows synchronizes
once a week. I changed the setting to sync every 6 hours. I copied the
registry keys and posted them here so that anyone else may do it as well.
Since Windows takes care of the time sync I don't have to run any programs or
applets to do it.
lol
Ghod, I just love this.
Boxes losing time is a minor problem that just seemed to mysteriously
appear. Over the years I've seen it blamed on motherboards, applications,
networks, etc. I've seen all kinds of fixes, but have never seen it
explained so well, or so simply repaired.
Thanks
-ralph
>Boxes losing time is a minor problem that just seemed to mysteriously
>appear. Over the years I've seen it blamed on motherboards, applications,
>networks, etc. I've seen all kinds of fixes, but have never seen it
>explained so well, or so simply repaired.
Thank you! I appreciate the comment.
Many times I've turned on old computers that hadn't been run in months or even
a couple years. The clock was usually fairly accurate (within maybe 10 to 20
seconds) because the RTC (real time clock) is as accurate as a wristwatch.
I'm actually surprised that neither Windows nor the BIOS makers have thought
to update the system clock against the RTC more often than at bootup. Heck,
they could do it once an hour or every 10 minutes or whatever and it wouldn't
be any problem. They have a perfectly fine clock onboard and they're not
using it much.
But, the Windows registry time polling tweak takes care of all that anyway.
> As for me, I just changed the update interval to sync every 6 hours
> instead of
> once a week, so I don't need to run anything to make sure my clock is
> synchronize more often than once a week.
>>Can you explain that sentence to me? It sounds like you totally
Okay, but in the original post you said you "don't need to run
anything...more often than once a week," suggesting that you DO need to run
something once a week, just not any more frequently than that. Then in your
reply to me you said to don't need to run any programs at all. See my
confusion?
Of course, when I decide to click the link the site is down for maintenance
:-S
Full link gives 404 error, domain only tells me that it is undergoing
maintenance.
I'll try again later. Thanks, Saga
http://web.archive.org/web/20080822214340/http://tf.nist.gov/service/its.htm
Thanks Nobody! Saga
>