Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I 've to get the System Date from another PC
Message
De
01/09/1998 02:19:19
 
 
À
31/08/1998 21:26:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00131444
Message ID:
00131802
Vues:
15
>>>>I'm developing a multiuser application (not a Client/server anyway) and I've the need to get the datetime() of a master PC to synchronize (I think I made a mistake but I don't want to get the dictionary) all the other PC with that one.
>>>>How can I do to do it ?
>>>
>>>Unfortunately, it depends on the type of machine being used as the master PC, and the network environment. On Novell networks, if all your systems use the same server, and use login scripts, they will be synced to the clock on the Novell server every time they reboot, and there is a Novell API call to read the clock of the default server. In a Microsoft networking environment, you can synchronize to that station's clock using the DOS command line:
>>>
>>> NET TIME \\computername /SET /YES
>>>
>>>If the machine is in another workgroup or domain, you will need additional parameters. See the built-in help for the NET TIME command by entering:
>>>
>>> NET TIME /? | MORE
>>>
>>>at a DOS command prompt.
>>>
>>>There is a Windows API call, NetRemoteTOD(), available to Windows NT 3.51 or later, and to Win98, but not to Win95 or Win3.x, that will request the time from a remote system acting as a time server. Short of that, you could create an out-of-process COM server that reported the time via a method call; you would run it on one of your machines which would become the server, and other machines would then attach to it via CREATEOBJ() and invoke the method when they wanted to read the server clock.
>>
>>
>>
>>I'm working under W95 environment, so I guess I cannot use the DOS command you told me unless I suppose That the master PC will be On before all other PCs even though I could turn a PC on before the master just ro run another application.
>>Am'I right ?
>
>Nope - the DOS command is available on Win95, Win98 and WinNT, and can be invoked by the VFP RUN command. You would need to know the name of the machine designated as the time server, so that all machines direct their reference to that machine for synchronization. I'm not certain what response comes back if the designated time server is not available at the time a synchrnization request is made, but you'd have that problem no matter what solution you attempted to use.


It works just fine.

I tried using the command NET TIME \\computername /SET /YES
and my computer's date and time was set to the computer connected.
Both the systems I used are on WIN95 and are connected in a single domain.

My Idea is store your Computer's time and date in a variable and then issue the above command which sets your computer's date and time , then use datetime() function to get the dat and time (which you want) and reset your computer 's date and time back to original. Note you cannot set system's date and time using any of VFP commands ,so use Run/N date ,run/n time to set the date and time back.

It solves the problem.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform