// Set Date & Time
public struct SystemTime
{
public ushort Year;
public ushort Month;
public ushort DayOfWeek;
public ushort Day;
public ushort Hour;
public ushort Minute;
public ushort Second;
public ushort Millisecond;
};
[DllImport("kernel32.dll", EntryPoint = "GetSystemTime", SetLastError = true)]
public extern static void Win32GetSystemTime(ref SystemTime st);
[DllImport("kernel32.dll", EntryPoint = "SetSystemTime", SetLastError = true)]
public extern static bool Win32SetSystemTime(ref SystemTime st);
// ....
public static void Test()
{
SystemTime newTime = new SystemTime();
newTime.Year = (ushort)2005;
newTime.Month = (ushort)12;
newTime.Day = (ushort)2;
newTime.Hour = (ushort)12; //UTC time (if you are in UTC+2 zone then you'll put here: time - 2h)
newTime.Minute = (ushort)42;
newTime.Second = (ushort)11;
Win32SetSystemTime(ref newTime);
}
Saturday, May 30, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment