Link to home
Start Free TrialLog in
Avatar of lospilotos
lospilotos

asked on

GetSystemTime returns zero hours, minute, second and millisecond

Hi!

Trying to get the system time using the Windows API GetSystemTime. It runs but returns zero for hour, minute, second and millisecond.

Using VB.NET in Visual Studio 2010 on a Windows 7 x86 machine.

Code below:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Public Class clsSocket

    Private Declare Sub GetSystemTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME)

     Private Structure SYSTEMTIME
        Public wYear As Integer
        Public wMonth As Integer
        Public wDayOfWeek As Integer
        Public wDay As Integer
        Public wHour As Integer
        Public wMinute As Integer
        Public wSecond As Integer
        Public wMilliseconds As Integer
    End Structure

    Public Sub CheckTime()

        Dim StartTime As SYSTEMTIME
        Dim EndTime As SYSTEMTIME

        GetSystemTime(StartTime)

   System.Diagnostics.Debug.WriteLine("Start: " & StartTime.wSecond & "." & StartTime.wMilliseconds & " End: " & EndTime.wSecond & "." & EndTime.wMilliseconds)
   
End Sub
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Any ideas?

Thanks in advance!

/Lospilotos
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lospilotos
lospilotos

ASKER

ToString("HH:mm:ss.fff") did the trick.