Setting the time requires elevated privileges.
When using
SetSystemTime
as suggested by OriginalGriff, your application must have the
SE_SYSTEMTIME_NAME
privilege which is not set for non-administrative accounts.
Other methods like changing the automatic time update configuration require administrative privileges. An example is the command line tool to configure the time service:
Windows Time Service Tools and Settings: Windows Time Service[
^].
So from the security point of view, the best option is to use
SetSystemTime
and give your application only the
SE_SYSTEMTIME_NAME
privilege rather full adminstrative privileges.
An even better option would be letting your application check if the actual time is correct by comparing with data from a net time service. You can than inform the user if the difference is too large asking for setting the time (or just enable the Windows time service).