VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "dwTime"
Attribute VB_Creatable = True
Attribute VB_Exposed = True
Option Explicit

' Class dwTime
' System time manipulation class
' Copyright (c) 1996 by Desaware Inc.
' Part of the Desaware API Classes Library
' All rights reserved

#If Win32 Then
Private Declare Sub apiGetLocalTime Lib "kernel32" Alias "GetLocalTime" (lpSystemTime As SYSTEMTIME)
Private Declare Function apiGetTickCount& Lib "kernel32" Alias "GetTickCount" ()
Private Declare Function apiSetSystemTime& Lib "kernel32" Alias "SetSystemTime" (lpSystemTime As SYSTEMTIME)
#Else
Private Declare Function apiGetTickCount& Lib "user" Alias "GetTickCount" ()
#End If 'WIN32


Public Function GetLocalTime() As dwSystemTime
Attribute GetLocalTime.VB_HelpID = 2344
Attribute GetLocalTime.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim tmpSysTime As SYSTEMTIME
    Dim tmpDwSysTime As New dwSystemTime

    apiGetLocalTime tmpSysTime
    tmpDwSysTime.CopyFromSYSTEMTIME agGetAddressForObject(tmpSysTime)
    Set GetLocalTime = tmpDwSysTime
#Else
    RaiseError DWERR_NOTINWIN16, "dwSystemTime"
#End If
End Function

Public Function GetTickCount() As Long
Attribute GetTickCount.VB_HelpID = 2356
Attribute GetTickCount.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    GetTickCount = apiGetTickCount()
End Function

Public Sub SetSystemTime(lpSystemTime As dwSystemTime)
Attribute SetSystemTime.VB_HelpID = 2343
Attribute SetSystemTime.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim tmpSysTime As SYSTEMTIME
    Dim ret&

    lpSystemTime.CopyToSYSTEMTIME agGetAddressForObject(tmpSysTime)
    ret& = apiSetSystemTime(tmpSysTime)
    If ret& = 0 Then RaiseError DWERR_APIRESULT, "dwSystemTime"
#Else
    RaiseError DWERR_NOTINWIN16, "dwSystemTime"
#End If
End Sub

