I\'m having a hard time getting SetSystemTime working in my C# code. SetSystemtime is a kernel32.dll function. I\'m using P/invoke (interop) to call it. SetSystemtime retu
You can't just add 3000 to the seconds field. You need to specify a number of seconds between 0 and 60. You need to adjust the seconds, minutes, hours, etc fields so that they are all within a valid range.
Edit
The simplest way would actually be to call SystemTimeToFileTime then add numSeconds * 10000
to the value it gives back, and then call FileTimeToSystemTime to convert back to a SystemTime.
There is a .Net method to set the time; it's just not available in C# by default. If you add a reference to Microsoft.VisualBasic
to your project then you can just write:
Microsoft.VisualBasic.DateAndTime.TimeOfDay = DateTime.Now.AddSeconds(3000).AddMilliseconds(80);