Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Server Time
Message
 
À
01/04/2004 20:09:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00891634
Message ID:
00892409
Vues:
22
You can use WMI to get the time of any computer:
? GetServerTime('ServerName')

Function GetServerTime(tcComputer)
local lcComputer, loWMIService, loOperatingSystem, loOS, lcDateTime, ltDateTime

lcComputer		= Iif(Vartype(tcComputer)='C', tcComputer, 'LocalHost')
loWMIService		= GetObject("winmgmts:\\" + lcComputer + "\root\cimv2")

loOperatingSystem	= loWMIService.ExecQuery("Select * from win32_OperatingSystem")
for each loOS in loOperatingSystem
  lcDateTime		= loOS.LocalDateTime
next
ltDateTime		= Ctot(Transform(lcDateTime, '@R 9999-99-99T99:99:9999'))
return ltDateTime
This assumes that all computers are in the same TimeZone, otherwise you need to analize the last digits of lcDateTime to adjust it.

Hugo
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform