Re: How to get TIME from NTP



Gerhard Gentele napsal(a):
Hi Jan,
yes I know that XP is offering a timeserver option. The point is that I make
cash register programs for restaurants. On most of their touch registers we
have W2K running and W2K don't offers this button. Some of them use the so
called Orderman (device to order wireless). These handhelts a terminals that
are controlled from a statemachine program (you can control up to 10 devices
with one PC over a RS232 port). To have everywhere the same time was the
customers request. Since all the used programes are from us it would be the
most easy way to do it from the timestuff from the already running (VFP9)
application. Then nobody has to install anything (besides a new PRG EXE).
By the way. The Navi server kicket me out (there was now refreshings anymore
after a few experiments.

But look at this "forgotten secret" below: It gives the time from the
CAESIUM Timeserver in Braunschweig Germany (they make the time there
(smile)). The batch file below is doing the job perfect with WINDOWS-DOS
commands. The only not so nice effect is that written in VFP with the RUN
"!" command opens a DOSBOX and that don't looks to good. Second negative
effect is when the date of the PC don't matches the actual date it don't
updates the time. But for most (adjusting) needs it will do a good job.
Do you have any idea on how to pack this below UNVISIBLE (without the RUN
command) in foxpro?

use ShellExecute

declare INTEGER ShellExecute in shell32 INTEGER handle, ;
STRING @ oper, STRING @ ifile, STRING @ iparam, ;
STRING @ ipath, INTEGER showcmd

* showcmd 1 visible 0 hidden

lcFileName = "AdjustTime.bat"
shellexecute(0, "open", lcFileName, "", "c:\", 0)


More about ShellExecute in attachment or consult MSDN:
http://search.msdn.microsoft.com/Default.aspx?brand=msdn&locale=en-us&query=shellexecute


rem getting time from Braunschweig PTB timeserver
echo off
cls
net stop w32time
rem The adress from the PTB server first adress is: ptbtime1.ptb.de and
second adress ptbtime2.ptb.de
rem one server is always running
NET TIME /SETSNTP:ptbtime1.ptb.de

NET TIME /SETSNTP:ptbtime1.ptb.de /SET /YES

(run "NET HELP TIME" to see short help)

w32tm -once
net start w32time
echo ATOMZEIT IN BRAUNSCHWEIG ABGEHOLT
rem pause

Greetings Gerhard


Hoffentlich hilft es.
Tschuess

Attachment: ShellExecute.zip
Description: Binary data


Loading