Ejemplo n.º 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;
         }
     }
 }
Ejemplo n.º 2
0
 public static extern bool SetSystemTime([In] ref NTPTime.SYSTEMTIME st);
Ejemplo n.º 3
0
 internal static extern bool SetLocalTime(ref NTPTime.SYSTEMTIME lpSystemTime);