PDA

View Full Version : سوال: تنظیم ساعت سیستم با استفاده از 3 تا textBox



mmbarname
پنج شنبه 17 آذر 1390, 11:29 صبح
sلام چجوری میتونم با استفاده از 3 تا textBox زمان سیستم رو تغییر بدم؟:خجالت:

abdullah20
پنج شنبه 17 آذر 1390, 12:11 عصر
using System.Runtime.InteropServices;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public struct SYSTEMTIME
{
public short wYear;
public short wMonth;
public short wDayOfWeek;
public short wDay;
public short wHour;
public short wMinute;
public short wSecond;
public short wMilliseconds;
}

[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetSystemTime([In] ref SYSTEMTIME st);
private void button2_Click(object sender, EventArgs e)
{
SYSTEMTIME st = new SYSTEMTIME();

st.wYear = 2003; // must be short
st.wMonth = 5;
st.wDay = 22;
st.wHour = 0;
st.wMinute = 0;
st.wSecond = 0;
SetSystemTime(ref st); // invoke this method.
}
}
}