[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

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?
  • 2
1 Solution
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")
API Method from AllAPI:

    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
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.


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now