PDA

View Full Version : تغییر Time ویندوز



Visual C# Express Edition
دوشنبه 30 بهمن 1385, 21:44 عصر
ببخشید می خواستم بدونم چگونه می شه Time ویندوز را با یک کد تغییر دهیم لطفا راهنمایی کنید. متشکرم.:متفکر:

ali_kolahdoozan
دوشنبه 30 بهمن 1385, 22:56 عصر
using System;
using System.Runtime.InteropServices;

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;
}


public class MyTimeAdjuster
{
[DllImport("kernel32.dll")]
public static extern bool GetSystemTime(ref SystemTime systemTime);
[DllImport("kernel32.dll")]
public static extern bool SetSystemTime(ref SystemTime systemTime);

void SetNewTime(short hour, short minutes)
{
SystemTime st = new SystemTime();
GetSystemTime(ref st);
st.wHour = hour;
st.wMinute = minutes;
SetSystemTime(ref st);
}

public static void Main(string[] args)
{
MyTimeAdjuster myTime = new MyTimeAdjuster();
myTime.SetNewTime( 12, 50);
}
}