SetSystemTime (coredll)
Last changed: -63.163.61.3

.
Summary
TODO - a short description

C# Signature:

[DllImport("coredll.dll", SetLastError=true)]
static extern TODO SetSystemTime(TODO);

VB Signature:

    <DllImport("coredll.dll")> _
    Private Shared Function SetSystemTime(ByRef time As SYSTEMTIME) As Boolean
    End Function

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Imports System.Runtime.InteropServices

Public Class Form1

    Inherits System.Windows.Forms.Form
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu

#Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    MyBase.Dispose(disposing)
    End Sub

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Private Sub InitializeComponent()
    Me.MainMenu1 = New System.Windows.Forms.MainMenu
    Me.Button1 = New System.Windows.Forms.Button
    '
    'Button1
    '
    Me.Button1.Location = New System.Drawing.Point(56, 160)
    Me.Button1.Size = New System.Drawing.Size(128, 64)
    Me.Button1.Text = "Button1"
    '
    'Form1
    '
    Me.Controls.Add(Me.Button1)
    Me.Menu = Me.MainMenu1
    Me.Text = "Form1"

    End Sub

#End Region

    Private Structure SYSTEMTIME
    Public Year As Short
    Public Month As Short
    Public DayOfWeek As Short
    Public Day As Short
    Public Hour As Short
    Public Minute As Short
    Public Second As Short
    Public Milliseconds As Short
    End Structure

    <DllImport("coredll.dll")> _
    Private Shared Function SetSystemTime(ByRef time As SYSTEMTIME) As Boolean
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim idag As DateTime = Now().AddHours(1).AddMinutes(2).ToUniversalTime
    Dim s As New SYSTEMTIME
    s.Year = idag.Year
    s.Month = idag.Month
    s.DayOfWeek = idag.DayOfWeek
    s.Day = idag.Day
    s.Hour = idag.Hour
    s.Minute = idag.Minute
    s.Second = idag.Second
    s.Milliseconds = idag.Millisecond

    SetSystemTime(s)
    End Sub

End Class

Alternative Managed API:

Do you know one? Please contribute it!

Documentation