good day to everybody
I wanted that my workstation clock will be updated at the server just at the click of a button.
So, How do I synchronize the system clock in my workstation with the system clock at the server using vfp .
Thank you very much for the help

How do I synchronize my workstation system clock with the server clock?
lpasquali
How to use the NetRemoteTOD function to obtain date and time information from a server
http://support.microsoft.com/kb/249716/EN-US/
Another way is for you to create an empty temp file in the server (maybe using STRTOFILE() ) then use ADIR to read the timestamp, then delete the file.
HTH
mEmENT0m0RI
So this will automatically change the clients system clock() or just shown the server's time . My understanding is that it just show the time at the server but will not automatically change it.
Because I want that every time my workstation will start it will automatically set its time through the server's system clock, by adding a code in the init event of my form, it will automatically set the time.
But my problem is how it will be done in VFP, by not double clicking the clock at the right and change it manually.
Seungho Nam
Scott Cairney
Assuming you are a local admin and have rights to connect to the server you can use WMI to do this:
cServer = "SERVERNAME"
oServerWMI = getobject("winmgmts://" + cServer + "/root/CIMV2")
colOS = oServerWMI.ExecQuery("select * from win32_operatingsystem")
for each oOS in colOS
* There is only one OS but we have to enumerate to get it:
dServerTime = oOS.LocalDateTime()
next
* dServerTime
* Time is in CIF DateTime Format... but we don't need to decrypt it
* as we can just pass it to SetDateTime()
cClient = "." && local computer
* We need to request SYSTEMTIME privilege:
oClientWMI = getobject("winmgmts:{(Systemtime)}//" + cClient + "/root/CIMV2")
colOS = oClientWMI.ExecQuery("select * from win32_operatingsystem")
for each oOS in colOS
nResult = oOS.SetDateTime(dServerTime)
if nResult = 0
"Success"
else
"Failed with a code of " + transform(nResult)
endif
next
nadim
Local ltNow, ltTest
ltNow = Datetime()
ltTest = {^2000/02/29 21:15}
'Now', m.ltNow
SetComputerClock(m.ltTest)
'Changed to', Datetime()
SetComputerClock(m.ltNow)
'Restored', Datetime()
Function SetComputerClock
Lparameters ttTime2Set
Local cNewTime
Declare Integer SetLocalTime In win32api String @ lpTime
* Set to m.ttTime2Set
cNewTime = ;
Num2Word(Year(m.ttTime2Set))+;
Num2Word(Month(m.ttTime2Set))+;
Num2Word(0)+;
Num2Word(Day(m.ttTime2Set))+;
Num2Word(Hour(m.ttTime2Set))+;
Num2Word(Minute(m.ttTime2Set))+;
Num2Word(Sec(m.ttTime2Set))+;
Num2Word(0)
SetLocalTime(@cNewTime)
SetLocalTime(@cNewTime)
Endfunc
Function Num2Word
Lparameters tnDecimal
Return Chr(m.tnDecimal%256)+Chr(Int(m.tnDecimal/256))
Endfunc
PS: Calling SetLocalTime twice is NOT a typo.
Jean Baronas