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?
 
Antagony1960Connect With a Mentor Commented:
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.