Reputation: 140
This is my code:
[System.Runtime.InteropServices.DllImport("kernel32", SetLastError =true)]
private static extern bool GetSystemTime(out SYSTEMTIME systemTime);
[System.Runtime.InteropServices.DllImport("kernel32", SetLastError =
true)]
private static extern bool SetSystemTime(ref SYSTEMTIME systemTime);
public struct SYSTEMTIME
{
public short Year;
public short Month;
public short DayOfWeek;
public short Day;
public short Hour;
public short Minute;
public short Second;
public short Milliseconds;
}
private void Form1_Load(object sender, EventArgs e)
{
DateTime serverTime = DateTime.Now;
SYSTEMTIME zaman = new SYSTEMTIME();
zaman.Day = 25;
zaman.Month = 9;
zaman.Year = 2010;
zaman.Hour = 14;
zaman.Minute = 45;
SetSystemTime(ref zaman);
label1.Text = zaman.Day.ToString();
label2.Text = zaman.Month.ToString();
label3.Text = zaman.Year.ToString();
}
The situation I want to do is to set the data I entered as time in windows.
The error I got: Can't find PInvoke DLL 'kernel32'.
How can fix this? Any ideas will be good for me.
Upvotes: -1
Views: 68