0
私は時間を変更しようとしていますが、時刻を00:00に変更しようとすると、代わりに08:00になりますか? UTC + 8のタイムゾーンを考慮していますか?C#でDateTimePickerを使用してシステムの日付と時刻を変更していますか?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace LibraryAdmin
{
public partial class Form41 : Form
{
public Form41()
{
InitializeComponent();
}
public struct SystemTime
{
public ushort Year;
public ushort Month;
public ushort DayOfWeek;
public ushort Day;
public ushort Hour;
public ushort Minute;
public ushort Second;
public ushort Millisecond;
};
[DllImport("kernel32.dll", EntryPoint = "GetSystemTime", SetLastError = true)]
public extern static void Win32GetSystemTime(ref SystemTime sysTime);
[DllImport("kernel32.dll", EntryPoint = "SetSystemTime", SetLastError = true)]
public extern static bool Win32SetSystemTime(ref SystemTime sysTime);
private void Form41_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
SystemTime updatedTime = new SystemTime();
updatedTime.Year = (ushort)dateTimePicker1.Value.Year;
updatedTime.Month = (ushort)dateTimePicker1.Value.Month;
updatedTime.Day = (ushort)dateTimePicker1.Value.Day;
updatedTime.Hour = (ushort)((dateTimePicker2.Value.Hour)) ;
updatedTime.Minute = (ushort)dateTimePicker2.Value.Minute;
updatedTime.Second = (ushort)dateTimePicker2.Value.Second;
Win32SetSystemTime(ref updatedTime);
}
private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
this.dateTimePicker2.Value.ToFileTimeUtc();
}
}
}
偽のアラーム!できます!ありがとうございました!!!! –