Getting Date/Time from LAN Machine and Setting Date/Time on Client 
Author Message
 Getting Date/Time from LAN Machine and Setting Date/Time on Client

Help!  

I have users in my domain who like to experiment with setting the system
time on their machine just "because its fun".  Invariably they wind up
messing up the time to the point that some things running (namely a
Database with Timestamp fields in it) wind up getting out of sync.  Elapsed
time (Time2 - Time1) is not accurate.

My cure is to add a chunck of code to my program so that whenever the form
is activated (focused) a call is made to another machine in the domain
(access is given at the console to myself only) through the LAN and gets
the time from that machine and then sets the system time on the machine
running my program.  This way they can mess with the time on their machines
"just because its fun" but it won't prevent my programs from being in sync
at all times.

Delphi does not have a native function to do this, so I must use the Win
API (or NAPI to get the time and Win API to set it).  I've done some
investigating but reading MicroSludge's text material I have available is
like reading Swahili to me.  Needless to say I can't speak Swahili.

Has anyone ever had to accomplish what I want done and can provide some
indication of what needs to occur?

I found the following function calls in Win API...

NetServerGetInfo
SetSystemTime

would using these two functions work in my case?  and if so, how would I go
about building an ObjectPascal "wrapper" around them so I can reuse this
code at will and use only native Delphi?

My domain is mostly Win95 Clients and WinNT 4.0 Servers with a few NT
Workstation 4.0 Clients.

Thanks ahead of time!

-Perry Way
==================================
Remove KILLSPAM to send me email

==================================



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting Date/Time from LAN Machine and Setting Date/Time on Client

 The attached file contains the project to get Server's date/time, the
setting of client's clock is left to you.

To test the GetServerTime procedure, set the client's clock to some way off
time, then run the program and click the "Check Time on Server" button and
the server's time should be shown.
------------------------------------------------------

Binary Engineers                               Software Developer
http://www.computerbargain.com/binary


Quote:
>Help!

>I have users in my domain who like to experiment with setting the system
>time on their machine just "because its fun".  Invariably they wind up
>messing up the time to the point that some things running (namely a
>Database with Timestamp fields in it) wind up getting out of sync.  Elapsed
>time (Time2 - Time1) is not accurate.

>My cure is to add a chunck of code to my program so that whenever the form
>is activated (focused) a call is made to another machine in the domain
>(access is given at the console to myself only) through the LAN and gets
>the time from that machine and then sets the system time on the machine
>running my program.  This way they can mess with the time on their machines
>"just because its fun" but it won't prevent my programs from being in sync
>at all times.

>Thanks ahead of time!

>-Perry Way
>==================================
>Remove KILLSPAM to send me email

>==================================

begin 666 svrtime.zip
<encoded_portion_removed>
end


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Getting system time and date.

2. Problems getting command.com's date and time with TP6

3. Date only or Date and Time ?

4. Setting Time/Date

5. Get/Set DIRECTORY information (date/time)

6. Getting file *creation* date, not modified date

7. Date or Time Only with TDateTime

8. date/time question

9. Interbase date time question

10. Date/Time format using D1/Oracle

11. date & time fields

12. Julian date / time formats.

 

 
Powered by phpBB® Forum Software