سلام
راه اول :
System.Diagnostics.Process.Start("CMD", "/C TIME 01:21");
راه دوم :
using System.Runtime.InteropServices;
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern bool SetLocalTime(ref SYSTEMTIME lpSystemTime);
[StructLayout(LayoutKind.Sequential)]
internal struct SYSTEMTIME
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek; // ignored for the SetLocalTime function
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
}
private void button1_Click(object sender, EventArgs e)
{
SYSTEMTIME time = new SYSTEMTIME();
time.wDay = 1;
time.wMonth = 5;
time.wYear = 2011;
time.wHour = 12;
time.wMinute = 15;
if (!SetLocalTime(ref time))
{
// The native function call failed, so throw an exception
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
موفق باشی