在 Windows 上使用 C 或 C++ 更改系统时间

Change system time using C or C++ on Windows

本文关键字:C++ 系统 时间 Windows      更新时间:2023-10-16

如何使用 C 或 C++ 更改 Windows 上的系统时间?

我搜索了互联网,但找不到它。

点击此链接 : http://learnhacking.in/c-program-to-set-change-current-system-date/

但它不起作用。

在Windows中,您可以通过GetSystemTime(以及一些不同的C/C++标准库函数)获取时间,并通过SetSystemTime设置时间

请注意,您需要在 Windows 中具有某些权限才能更改时间,因此如果您没有这些权限,则需要让管理员授予您更多权限。

您可以通过包含 windows.h 标头并调用 SetSystemTime(...) 函数来设置它。