コード例 #1
0
        private void UpdateRece(string msg)
        {
            DateTime time;

            if (DateTime.TryParse(msg, out time))
            {
                SYSTEMTIME t = new SYSTEMTIME();
                t.Year   = (short)time.Year;
                t.Month  = (short)time.Month;
                t.Day    = (short)time.Day;
                t.Hour   = (short)(time.Hour - 8);
                t.Minute = (short)time.Minute;
                t.Second = (short)time.Second;
                bool v = NewTimeWin32.SetSystemTime(ref t);
                if (v)
                {
                    this.GetMsgList.Items.Add("The Time Is Success!Now Time Is:" + DateTime.Now);
                }
                else
                {
                    this.GetMsgList.Items.Add("The Time Is Faild!Now Time:Is" + DateTime.Now);
                }
            }
            else
            {
                this.GetMsgList.Items.Add("The Time Is Faild!Can't Convert Time Object");
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            mYear  = monthCalendar1.SelectionRange.Start.Year;
            mMonth = monthCalendar1.SelectionRange.Start.Month;
            mDay   = monthCalendar1.SelectionRange.Start.Day;

            SYSTEMTIME t = new SYSTEMTIME();

            t.Year   = (short)mYear;
            t.Month  = (short)mMonth;
            t.Day    = (short)mDay;
            t.Hour   = (short)(dateTimePicker1.Value.Hour - 8);
            t.Minute = (short)dateTimePicker1.Value.Minute;
            t.Second = (short)dateTimePicker1.Value.Second;
            bool v = NewTimeWin32.SetSystemTime(ref t);

            if (v)
            {
                MessageBox.Show("Success!");
            }
            else
            {
                MessageBox.Show("Faild!");
            }
        }