Results 1 to 3 of 3

Thread: Using SetSystemTime

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352

    Using SetSystemTime

    How would I design an operation that stores the current time to the millisecond, then changes the current time to some other time accurate to a millisecond, and then when it is done, restores the time when the operation started(i.e the storage of the currrent time). Thank you for your help.
    Sincerely,
    Joseph

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    To get the current time in milliseconds try
    VB Code:
    1. Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
    2.  
    3. Private Type SYSTEMTIME
    4.     wYear As Integer
    5.     wMonth As Integer
    6.     wDayOfWeek As Integer
    7.     wDay As Integer
    8.     wHour As Integer
    9.     wMinute As Integer
    10.     wSecond As Integer
    11.     wMilliseconds As Integer
    12. End Type
    13.  
    14. Private Function TimeToMillisecond() As String
    15.    
    16.     Dim DaAnswer As String
    17.     Dim MyMillTime As SYSTEMTIME
    18.    
    19.     On Error Resume Next
    20.     GetSystemTime MyMillTime
    21.     DaAnswer = Hour(Now) & ":" & Minute(Now) & ":" & Second(Now) & ":" & MyMillTime.wMilliseconds
    22.     TimeToMillisecond = DaAnswer
    23.    
    24. End Function
    I'm a little confused after this however. ??You want to get the current time in milliseconds, convert it to "something else" and then convert is back??

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352

    maybe this will clarify

    I want to get the current time(store it in currenttime). Then, I want to set the time to some predefined time(set the time to newtime). Then after I execute some code I want to set the time back to currenttime(the value stored earlier). Thanks for the help
    Joe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width