当前位置:网站首页>change system time

change system time

2022-06-10 13:00:00 YQ8023family

  • Add administrator privileges to programs  Insert picture description here
  • Code
//qint64 time_t1 = QDateTime::currentDateTime().toMSecsSinceEpoch();// return ms
	qint64 time_t1 = 16520974000;
	QDateTime datetime = QDateTime::fromMSecsSinceEpoch(time_t1);
	SYSTEMTIME st = {0};
	GetLocalTime(&st);
	st.wYear = datetime.date().year();
	st.wMonth = datetime.date().month();
	st.wDay = datetime.date().day();
	st.wHour = datetime.time().hour();
	st.wMinute = datetime.time().minute();
	st.wSecond = datetime.time().second();
	st.wMilliseconds = datetime.time().msec();
	bool state = SetLocalTime(&st);             // Return if the modification is correct true

	QDateTime time = QDateTime::currentDateTime();
	qDebug() << time.toString("yyyy-MM-dd hh:mm:ss.zzz") << "   state = " << state;
原网站

版权声明
本文为[YQ8023family]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101134051235.html