è in basic. Prova a tradurlo in c#
codice:
Private lpSystemTimeOLD As SYSTEMTIME
Declare Function SetLocalTime% Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME)
Declare Sub GetLocalTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME)
Structure SYSTEMTIME
Dim wYear As Short
Dim wMonth As Short
Dim wDayOfWeek As Short
Dim wDay As Short
Dim wHour As Short
Dim wMinute As Short
Dim wSecond As Short
Dim wMilliseconds As Short
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'imposta la data al 28/2/1999
GetLocalTime(lpSystemTimeOLD)
Dim lpSystemTime As SYSTEMTIME
With lpSystemTime
.wYear = 1999
.wMonth = 2
.wDay = 28
.wDayOfWeek = lpSystemTimeOLD.wDayOfWeek
.wHour = lpSystemTimeOLD.wHour
.wMinute = lpSystemTimeOLD.wMinute
.wSecond = lpSystemTimeOLD.wSecond
.wMilliseconds = lpSystemTimeOLD.wMilliseconds
End With
Dim er% = SetLocalTime(lpSystemTime)
If er = 0 Then MsgBox("Errore")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'ripristina la data
Dim lpSystemTime As SYSTEMTIME
GetLocalTime(lpSystemTime)
With lpSystemTime
.wYear = lpSystemTimeOLD.wYear
.wMonth = lpSystemTimeOLD.wMonth
.wDay = lpSystemTimeOLD.wDay
.wDayOfWeek = lpSystemTimeOLD.wDayOfWeek
End With
Dim er% = SetLocalTime(lpSystemTime)
If er = 0 Then MsgBox("Errore")
End Sub
Naturalmente è una finestra windows e non una pagina asp.net