예제 #1
0
 internal static void SetDate(DateTime vDate)
 {
     NativeTypes.SystemTime systime = new NativeTypes.SystemTime();
     SafeNativeMethods.GetLocalTime(systime);
     systime.wYear  = checked ((short)vDate.Year);
     systime.wMonth = checked ((short)vDate.Month);
     systime.wDay   = checked ((short)vDate.Day);
     if (UnsafeNativeMethods.SetLocalTime(systime) != 0)
     {
         return;
     }
     if (Marshal.GetLastWin32Error() == 87)
     {
         throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue"));
     }
     throw new SecurityException(Utils.GetResourceString("SetLocalDateFailure"));
 }
예제 #2
0
 internal static void SetTime(DateTime dtTime)
 {
     NativeTypes.SystemTime systime = new NativeTypes.SystemTime();
     SafeNativeMethods.GetLocalTime(systime);
     systime.wHour         = checked ((short)dtTime.Hour);
     systime.wMinute       = checked ((short)dtTime.Minute);
     systime.wSecond       = checked ((short)dtTime.Second);
     systime.wMilliseconds = checked ((short)dtTime.Millisecond);
     if (UnsafeNativeMethods.SetLocalTime(systime) != 0)
     {
         return;
     }
     if (Marshal.GetLastWin32Error() == 87)
     {
         throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue"));
     }
     throw new SecurityException(Utils.GetResourceString("SetLocalTimeFailure"));
 }
예제 #3
0
 internal static extern void GetLocalTime(NativeTypes.SystemTime systime);