Exemplo n.º 1
0
 internal static void SetDate(DateTime vDate)
 {
     NativeTypes.SystemTime systime = new NativeTypes.SystemTime();
     SafeNativeMethods.GetLocalTime(systime);
     systime.wYear  = (short)vDate.Year;
     systime.wMonth = (short)vDate.Month;
     systime.wDay   = (short)vDate.Day;
     if (Microsoft.VisualBasic.CompilerServices.UnsafeNativeMethods.SetLocalTime(systime) == 0)
     {
         if (Marshal.GetLastWin32Error() == 0x57)
         {
             throw new ArgumentException(GetResourceString("Argument_InvalidValue"));
         }
         throw new SecurityException(GetResourceString("SetLocalDateFailure"));
     }
 }
Exemplo n.º 2
0
 internal static void SetTime(DateTime dtTime)
 {
     NativeTypes.SystemTime systime = new NativeTypes.SystemTime();
     SafeNativeMethods.GetLocalTime(systime);
     systime.wHour         = (short)dtTime.Hour;
     systime.wMinute       = (short)dtTime.Minute;
     systime.wSecond       = (short)dtTime.Second;
     systime.wMilliseconds = (short)dtTime.Millisecond;
     if (Microsoft.VisualBasic.CompilerServices.UnsafeNativeMethods.SetLocalTime(systime) == 0)
     {
         if (Marshal.GetLastWin32Error() == 0x57)
         {
             throw new ArgumentException(GetResourceString("Argument_InvalidValue"));
         }
         throw new SecurityException(GetResourceString("SetLocalTimeFailure"));
     }
 }
 internal static void SetTime(DateTime dtTime)
 {
     NativeTypes.SystemTime systime = new NativeTypes.SystemTime();
     SafeNativeMethods.GetLocalTime(systime);
     systime.wHour = (short) dtTime.Hour;
     systime.wMinute = (short) dtTime.Minute;
     systime.wSecond = (short) dtTime.Second;
     systime.wMilliseconds = (short) dtTime.Millisecond;
     if (Microsoft.VisualBasic.CompilerServices.UnsafeNativeMethods.SetLocalTime(systime) == 0)
     {
         if (Marshal.GetLastWin32Error() == 0x57)
         {
             throw new ArgumentException(GetResourceString("Argument_InvalidValue"));
         }
         throw new SecurityException(GetResourceString("SetLocalTimeFailure"));
     }
 }
 internal static void SetDate(DateTime vDate)
 {
     NativeTypes.SystemTime systime = new NativeTypes.SystemTime();
     SafeNativeMethods.GetLocalTime(systime);
     systime.wYear = (short) vDate.Year;
     systime.wMonth = (short) vDate.Month;
     systime.wDay = (short) vDate.Day;
     if (Microsoft.VisualBasic.CompilerServices.UnsafeNativeMethods.SetLocalTime(systime) == 0)
     {
         if (Marshal.GetLastWin32Error() == 0x57)
         {
             throw new ArgumentException(GetResourceString("Argument_InvalidValue"));
         }
         throw new SecurityException(GetResourceString("SetLocalDateFailure"));
     }
 }
 internal static extern int SetLocalTime(NativeTypes.SystemTime systime);