Stylist Diaryblueday.blog.chinaunix.net
blueday
全部博文(292)
2011年(1)
2010年(4)
2009年(3)
2008年(6)
2007年(47)
2006年(63)
2005年(168)
ablewen
tiny-yao
pm_cu
sky555
cynthia
Bsolar
浪花小雨
格伯纳
q4993115
不一样的
shiming1
hd141283
yejia805
分类: C/C++
2007-05-26 21:21:25
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;namespace Qualification{ public partial class FormDateSet : Form { public FormDateSet() { InitializeComponent(); } //调用Kernel32.DLL [DllImport("Kernel32.dll")] public static extern void GetLocalTime(SystemTime st); [DllImport("Kernel32.dll")] public static extern void SetLocalTime(SystemTime st); [StructLayout(LayoutKind.Sequential)] public class SystemTime { public ushort wYear; public ushort wMonth; public ushort wDayOfWeek; public ushort wDay; public ushort Whour; public ushort wMinute; public ushort wSecond; public ushort wMilliseconds; } private void FormDateSet_Load(object sender, EventArgs e) { } private void timer1_Tick(object sender, EventArgs e) { SystemTime st = new SystemTime(); GetLocalTime(st); this.textBox1.Text = st.wYear.ToString()+"-"; this.textBox1.Text = this.textBox1.Text + st.wMonth.ToString() + "-"; this.textBox1.Text = this.textBox1.Text + st.wDay.ToString() + " "; this.textBox1.Text = this.textBox1.Text + st.Whour.ToString() + ":" + st.wMinute.ToString() + ":" + st.wSecond.ToString(); } private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { } private void Btn_set_Click(object sender, EventArgs e) { try { SystemTime st = new SystemTime(); st.wYear = (ushort)this.dateTimePicker1.Value.Year; st.wMonth = (ushort)this.dateTimePicker1.Value.Month; st.wDay = (ushort)this.dateTimePicker1.Value.Day; st.Whour = (ushort)this.dateTimePicker1.Value.Hour; st.wMinute = (ushort)this.dateTimePicker1.Value.Minute; st.wSecond = (ushort)this.dateTimePicker1.Value.Second; SetLocalTime(st); MessageBox.Show("系统时间设置成功!", "系统时间设置成功!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("系统时间设置失败!", "设置失败", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally {} } }}
上一篇:从爱到爱的路上
下一篇:二三层交换技术与路由技术对比
登录 注册