In my VB6 program I need to check few times per hour user has correct date/time on his station,

in a VB program I must be sure user has correct date and time while entering data, can  I "ping" some Internet site and take there correct date/time few times per hour and if needed update systemclock in Xp machine?
BIAPROAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roy WeilownerCommented:
an ugly. but  working way is

VB6 has a function called Shell which Runs an executable program and returns an integer containing the program's process ID if it is still running.

Write a temporary file (tempfile.txt) that contains the time command

time 10:01

then run the shell function

shell ("cmd.exe < tempfile.txt")
0
Antagony1960Commented:
API Method from AllAPI:

Private Type SYSTEMTIME
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Integer
End Type
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private Sub Form_Load()
    Dim lpSystemTime As SYSTEMTIME
    lpSystemTime.wYear = 2000
    lpSystemTime.wMonth = 1
    lpSystemTime.wDayOfWeek = -1
    lpSystemTime.wDay = 24
    lpSystemTime.wHour = 23
    lpSystemTime.wMinute = 26
    lpSystemTime.wSecond = 0
    lpSystemTime.wMilliseconds = 0
    'set the new time
    SetSystemTime lpSystemTime
End Sub
0
Antagony1960Commented:
My apologies BIAPRO, I misread your question and took it that you already had a method for getting the time from a server and just wanted a method for setting the system clock from that.

Check out this simple VB project download which uses a WinSock control to retrieve the server time. You should be able to adapt the code therein to your own needs.

http://www.freevbcode.com/ShowCode.asp?ID=1594
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.