Private Structure <StructLayout(LayoutKind.Sequential)> SYSTEMTIME Public wYear As Short Public wMonth As Short Public wDayOfWeek As Short Public wDay As Short Public wHour As Short Public wMinute As Short Public wSecond As Short Public wMilliseconds As Short End Structure
Private Declare Function SetSystemTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME) As Boolean
Dim lpSystemTime As SYSTEMTIME ' Fill the structure and call SetSystemTime(lpSystemTime)
Private Structure <StructLayout(LayoutKind.Sequential)> SYSTEMTIME Public w2006 As Short Public w01 As Short Public w11 As Short Public wW As Short Public w2 As Short Public w48 As Short Public w12 As Short Public w10 As Short End Structure
Private Declare Function SetSystemTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME) As Boolean
Dim lpSystemTime As SYSTEMTIME ' Fill the structure and call SetSystemTime(lpSystemTime)
Changing Windows Time
KevinC123
You can set the system time with the SetSystemTime method from kernel32.dll, here is an little example:
[DllImport("kernel32.dll")]
static extern bool SetSystemTime(ref SYSTEMTIME time);
Private Structure <StructLayout(LayoutKind.Sequential)> SYSTEMTIME
Public wYear As Short
Public wMonth As Short
Public wDayOfWeek As Short
Public wDay As Short
Public wHour As Short
Public wMinute As Short
Public wSecond As Short
Public wMilliseconds As Short
End Structure
Private Declare Function SetSystemTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME) As Boolean
Dim lpSystemTime As SYSTEMTIME
' Fill the structure and call
SetSystemTime(lpSystemTime)
I hope this helps.
pippo43
Is this right
[DllImport("kernel32.dll")]
static extern bool SetSystemTime(ref SYSTEMTIME time);
Private Structure <StructLayout(LayoutKind.Sequential)> SYSTEMTIME
Public w2006 As Short
Public w01 As Short
Public w11 As Short
Public wW As Short
Public w2 As Short
Public w48 As Short
Public w12 As Short
Public w10 As Short
End Structure
Private Declare Function SetSystemTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME) As Boolean
Dim lpSystemTime As SYSTEMTIME
' Fill the structure and call
SetSystemTime(lpSystemTime)
Michael Mullen
the Dll in the Compact framework is Coredll.dll
http://msdn2.microsoft.com/en-us/netframework/aa497275.aspx
Minad
When you are running this on a the Compact Framework the method is not found in "Kernel32.dll" but in "Core.dll".