Share via


How can I set the System Time from my c# Code??

Question

Saturday, December 12, 2015 5:10 PM

This doesn't work for lack of kernel32.dll

    [DllImport("kernel32.dll", EntryPoint = "SetSystemTime", SetLastError = true)]
    extern static bool Win32SetSystemTime(ref SystemTime sysTime);

Maybe can I call the settime function PowerShell routine from C# ?

Some idea?

All replies (9)

Saturday, December 12, 2015 10:08 PM | 1 vote

Try

http://stackoverflow.com/questions/30585900/how-to-set-system-time-in-windows-10-iot

and go with the using Power Shell scripts suggestion by kiran and GGleGrand to achieve this requirement.

riclh


Sunday, December 13, 2015 12:35 AM

Hi nicieri, have a look at this site: http://stackoverflow.com/questions/650849/change-system-date-programatically

This may help you as well.

Cheers.


Sunday, December 13, 2015 10:47 AM

In light of the various options that the above two methodologies describe, it may well be useful to have a way to launch Win32 items from UWP.

See here https://ms-iot.github.io/content/en-US/win10/samples/ProcessLauncherSample.htm

riclh


Saturday, December 26, 2015 6:10 PM

Yes, but I need In Windows IoT.

Some idea?


Saturday, December 26, 2015 6:11 PM

But not a function in Iot.

Some idea?


Saturday, December 26, 2015 6:19 PM

It IS a function in Win32 which you can call from UWP (with Admin privileges)

riclh


Sunday, December 27, 2015 4:41 PM | 1 vote

I would suggest changing time zone of the device through c#. We did this with our digital signage and works perfectly fine.


Monday, January 4, 2016 10:53 PM

anyone? , some answer proven and accurate ?


Monday, January 4, 2016 10:54 PM

anyone? , some answer proven and accurate ?