zoukankan      html  css  js  c++  java
  • 设置系统任务栏时间

    实现效果:

      

    知识运用:

      API函数SetSystemTime

    实现代码:

            [DllImport("kernel32.dll", CharSet = CharSet.Ansi)]
            public extern static bool SetSystemTime(ref SYSTEMTIME IpSystemTime);
            [StructLayout(LayoutKind.Sequential)]
            public struct SYSTEMTIME
            {
                public short Year; public short Month; public short DayOfWeek; public short Day;
                public short Hour; public short Minute; public short Second; public short Miliseconds;
            }
            int mYear;
            int mMonth;
            int mDay;
            private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
            {
                mYear = e.Start.Year;
                mMonth = e.Start.Month;
                mDay = e.Start.Day;
            }
    
            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); //系统默认UTC时间 要减8
                t.Minute = (short)dateTimePicker1.Value.Minute;
                t.Second = (short)dateTimePicker1.Value.Second;
                SetSystemTime(ref t);
            }
    

      

  • 相关阅读:
    服务器 空间
    android 手动打包
    sql server 2000 完全卸载 2
    apk 优化
    asp.net 画 数据图表
    java 运行 bat win linux
    vb 生成 批处理
    国内平台
    委托
    observer 观察者模式
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10309572.html
Copyright © 2011-2022 走看看