C++ set local pc time

Filip 831 Reputation points
2021-04-09T12:43:52.677+00:00

Hello Everybody.
How can i change the local time on my pc?
Is here way how can i change it with "windows.h"
I used this code but somewho is didn't change.
Thanks for answare.

include <windows.h>

include <stdio.h>

void main()
{
SYSTEMTIME st, lt;
GetLocalTime(&lt);
lt.wHour--;
SetLocalTime(&lt);
}

Developer technologies | C++
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 90,686 Reputation points
    2021-04-09T12:58:35.41+00:00

    You must enable the SE_SYSTEMTIME_NAME privilege, as said in the doc

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.