예제 #1
0
 public void method_0(string url)
 {
     if (!string.IsNullOrEmpty(url))
     {
         try
         {
             DateTime           networkTime = NTP.GetNetworkTime(url);
             NTPTime.SYSTEMTIME sYSTEMTIME  = new NTPTime.SYSTEMTIME()
             {
                 wHour         = (short)networkTime.Hour,
                 wMinute       = (short)networkTime.Minute,
                 wSecond       = (short)networkTime.Second,
                 wMilliseconds = (short)networkTime.Millisecond,
                 wDay          = (short)networkTime.Day,
                 wMonth        = (short)networkTime.Month,
                 wYear         = (short)networkTime.Year,
                 wDayOfWeek    = (short)networkTime.DayOfWeek
             };
             IntPtr token = WindowsIdentity.GetCurrent().Token;
             (new WindowsIdentity(token)).Impersonate();
             NTPTime.SetSystemTime(ref sYSTEMTIME);
             NTPTime.SetLocalTime(ref sYSTEMTIME);
             DateTime now = DateTime.Now;
         }
         catch (Exception exception)
         {
             string message = exception.Message;
         }
     }
 }
예제 #2
0
 public static extern bool SetSystemTime([In] ref NTPTime.SYSTEMTIME st);
예제 #3
0
 internal static extern bool SetLocalTime(ref NTPTime.SYSTEMTIME lpSystemTime);