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 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);