Nadee
Nadee

Reputation: 97

Change system date on Windows using Qt

What is the most appropriate method to change the system date (on Windows) programmatically using Qt4. I'm using Qt Creator 1.3.1.

Upvotes: 1

Views: 3371

Answers (1)

user362638
user362638

Reputation:

Use Windows API, GetLocalTime and SetLocalTime.

SYSTEMTIME localTime;
GetLocalTime(&localTime);

localTime.wHour = 21;
localTime.wMinute = 30;

if (SetLocalTime(&localTime) != 0)
{
    // ok
}
else
{
    // failed
}

Upvotes: 5

Related Questions