Using System;
Using System. Collections. Generic;
Using System. Text;
Using System. Runtime. InteropServices;
Namespace Fengyun
{
Public class Win32
{
# Region modify local system time
[DllImport ("Kernel32.dll")]
Private extern static void GetSystemTime (ref SYSTEMTIME lpSystemTime );
[DllImport ("Kernel32.dll")]
Private extern static uint SetLocalTime (ref SYSTEMTIME lpSystemTime );
[StructLayout (LayoutKind. Sequential)]
Private struct SYSTEMTIME
{
Public ushort wYear;
Public ushort wMonth;
Public ushort wDayOfWeek;
Public ushort wDay;
Public ushort wHour;
Public ushort wMinute;
Public ushort wSecond;
Public ushort wMilliseconds;
}
/// <Summary>
/// Synchronize the local time with the SQL server time
/// </Summary>
/// <Param name = "SqlServerTime"> time </param>
Public static void SetTime (DateTime SqlServerTime)
{
SYSTEMTIME st = new SYSTEMTIME ();
St. wYear = Convert. ToUInt16 (SqlServerTime. Year );
St. wMonth = Convert. ToUInt16 (SqlServerTime. Month );
St. wDay = Convert. ToUInt16 (SqlServerTime. Day );
St. wHour = Convert. ToUInt16 (SqlServerTime. Hour );
St. wMilliseconds = Convert. ToUInt16 (SqlServerTime. Millisecond );
St. wMinute = Convert. ToUInt16 (SqlServerTime. Minute );