Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Synch PC Clock to Server or Web
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Divers
Thread ID:
01001282
Message ID:
01001298
Vues:
78
If VFP solution is good for you (no ActiveX needed)

See: How to use the NetRemoteTOD function to obtain date and time information from a server http://support.microsoft.com/kb/249716/EN-US/

(or you can obtain atomtime with winsock from the internet)

And

Setting time could be something like the next (I'v taken this direct from settime method where ATOMtime is fetched from the Internet..., just look for the main routine hope to set time):
. * Fetch atomtime
.
.
* set system time
DECLARE SHORT SetLocalTime IN win32api STRING SystemTime
.
.
Local ;
  lSystemTime, ;
  lretval, ;
  ltOldTime, ;
  lni

m.lSystemTime = word2str(Year(m.ltDateTime)) + ;
  word2str(Month(m.ltDateTime)) + ;
  word2str(Dow(m.ltDateTime) - 1) + ;
  word2str(Day(m.ltDateTime)) + ;
  word2str(Val(Substr(Ttoc(m.ltDateTime),12,2))) + ;
  word2str(Val(Substr(Ttoc(m.ltDateTime),15,2))) + ;
  word2str(Val(Substr(Ttoc(m.ltDateTime),18,2))) + ;
  word2str(0)

m.ltOldTime = Datetime()

*!* Time to time SetLocalTime returns 0 "without no reason"
*!* Loop 3 times to make sure it's real error not a "wait state" error.
For m.lni = 1 To 3
  m.lretval = SetLocalTime(m.lSystemTime)
  If m.lretval # 0
    Exit
  Endif
Endfor

If m.lretval = 0

  * Assert !File("ASSERT.CHK") Message "SET TIME"

  m.lretval = -1

  *!* lnShow = 0 Silent mode
  *!* lnShow = 1 Statusbar
  *!* lnShow = 2 Messagebox
  *!* lnShow = 3 Staus bar and messagebox

  *!* Following values are Silent mode but if
  *!* online is changed then it is messaged.
  *!* lnShow = 10 Silent mode
  *!* lnShow = 11 Statusbar
  *!* lnShow = 12 Messagebox
  *!* lnShow = 13 Staus bar and messagebox

  Thisform.ShowMessage(m.cTimeSetError,64,"IP-Robot",2000,Iif(Thisform.Visible,3,1))

  If Thisform.lSavelog
    Strtofile(IIF(!m.lchange_12_24,"NIST ","AMPM ")+Ttoc(Datetime())+" ==> ?????????? ??:??:??" + CRLF, ;
      "IP-Robot.log",1)
  Endif


Else
  * Send the message that the time has changed.
  * IF Thisform.lTime_Send_Message
  *!* Send message to all toplevel windows that system time is changed
  SendMessage(HWND_BROADCAST, WM_TIMECHANGE, "", "")

  If m.lnShow > 0 And m.lnShow < 4 Or m.lnShow > 10 And m.lnShow < 14
    Thisform.ShowMessage(m.cTimeUpdMsg,64,"IP-Robot",2000,lnShow)
  Endif

  If Thisform.lSavelog
    Strtofile(IIF(!m.lchange_12_24,"NIST ","AMPM ")+Ttoc(m.ltOldTime)+" ==> "+Ttoc(Datetime()) + CRLF, ;
      "IP-Robot.log",1)
  Endif

  * Endif
Endif

* m.lretval = SendMessage(HWND_BROADCAST, WM_TIMECHANGE, "", "")

Return m.lretval

*--------------------

* Set system time stuff
Function word2str(wordval)
  * Function word2str.
  * Parameters: 16-bit value.
  * Returns: low-high format string for use in structures
  * requiring a WORD value.

  Local i, m.retstr

  m.retstr = ""
  For i = 8 To 0 Step -8
    m.retstr = Chr(Int(m.wordval/(2^i))) + m.retstr
    m.wordval = Mod(m.wordval, (2^i))
  Next

  Return m.retstr
AT
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform