Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

synchronice systemtime in workstations 1

Status
Not open for further replies.

eys

Programmer
Mar 5, 2001
28
MX
I want to set the systemtime from VFox and make server and workstations have the date and time.

How? Anybody can help? Excuse my poor span-glish.

Jose Carlos
 
Hi,
This is one part the solution.

1. Server must send to client datetime formatted as: yyyymmddho:mi:se (ho: hour;mi:minute; se:second )
Proc GetAndReturnDatetime

Retu Dtos(date)+time()
Endproc


2.Clients get string of datetime from server, it will SetSystemTime on client PC

kk = GetDateTimeStringFromServer()
yy = val(left(kk,4))
mm = val(subs(kk,5,2))
dd = val(subs(kk,7,2))
hh = val(subs(kk,9,2))
mi = val(subs(kk,12,2))
se = val(left(kk,2))
=SetSysTime(yy,mm,dd,hh,mi,se)

Proc SetSysTime

lpara pYear, pMonth, pDay, pHour, pMin , pSec

Decl long SetSystemTime in win32api string && string =space(40)
Decl long GetSystemTime in win32api string@ && string =space(40)
Declare long PostMessage in win32api long,long,long,long

local cBuff, t
cBuff=space(40)
=GetSystemTime(@cBuff)

* Year
cBuff = STUFF(cBuff, 1 , 2 , chr( mod(pYear,256)) + chr( int(pYear/256)))
* Month
cBuff = STUFF(cBuff, 3 , 2 , chr( mod(pMonth,256)) + chr( int(pMonth/256)))
* Day
cBuff = STUFF(cBuff, 7 , 2 , chr( mod(Pday,256)) + chr( int(pDay/256)))
* Hour
cBuff = STUFF(cBuff, 9 , 2 , chr( mod(phour,256)) + chr( int(phour/256)))
* Min
cBuff = STUFF(cBuff, 11 , 2 , chr( mod(pMin,256)) + chr( int(pMin/256)))
* Second
cBuff = STUFF(cBuff, 13 , 2 , chr( mod(pSec,256)) + chr( int(pSec/256)))

t=SetSystemTime(@cBuff)
=PostMessage (0xffff,0x1e,0,0)

Retu iif(t>0, .T.,.F.)


On server, you can use winsock to broadcast datetime on spicific port.
On clients, you can use winsock to listen to that port and capture datetime string.

If there is something unclear, pls reply
Hope it helps

Jimmy Le
nhan_tiags@yahoo.com
 
HI what I provide is not the VFP way, but you can use it to set through VFP

! NET TIME \\ServerName /SET /YES

This can be set as a Batch command and run.. or called from FoxPro.. or put in the login script.. in which ever way it suits.

This works for Windows or Netware networks.

:) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Thanks a lot Jimmy Le.

Ramani your are my hero, when I grow up wanna be like you (i'm 32 old).

Again, excuse span-glish (spanish-english kind of languaje)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top