hi expert
i write sample application for setting system time and system date programatically
my code contains :
step 1) I import the kernel.dll for GetSystemTime && SetSystemTime
Quote:
quote:[DllImport("kernel32.dll")]
|
Quote:
static extern bool SetSystemTime(ref SYSTEMTIME time);
[DllImport("kernel32.dll")]
static extern void GetSystemTime(out SYSTEMTIME lpSystemTime);
|
i write a structure such as follow
step 2 ) i write following structre
Quote:
quote:public struct SYSTEMTIME
|
Quote:
{
public short year;
public short month;
public short dayOfWeek;
public short day;
public short hour;
public short minute;
public short second;
public short milliseconds;
}
|
step 3) and finally i write in button1_click
Quote:
{
SYSTEMTIME time= new SYSTEMTIME();
GetSystemTime(out time);
time.hour = 12;
time.year = 2001;
SetSystemTime(ref time);
MessageBox.Show("system time and date hase been changed successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
|
and now my questions
1) as you see i set the hour to 12 but after clicking the button the system time seted to 4 PM , why?
2 )how can i set the year to 1386 ? in fact in above code where i set the year less than 2000 my code become ignore , why?
regards