【问题标题】:Change local time by C++ program通过 C++ 程序更改本地时间
【发布时间】:2010-08-15 11:46:06
【问题描述】:

现在我国的当地时间是:

3:43 PM   

我可以用 C++ 编写程序来将 Windows 7 系统上的时间更改为另一个时间吗?

例如将其设置为下午 5:00(增加)还是减少?

【问题讨论】:

  • 请提供更多上下文,如果需要,您想在哪个操作系统上更改系统时间?

标签: c++ windows-7


【解决方案1】:

在VC++中你可以试试。包括 Windows.h 头文件。

SetSystemTime Function

SYSTEMTIME st;
st.wYear = 2010;
st.wMonth = 5;
st.wDay = 2;
st.wHour = 7;
st.wMinute = 46;
st.wSecond = 31;
st.wMilliseconds = 345;
::SetSystemTime(&st);

【讨论】:

    【解决方案2】:
    #include Windows.h
    
    BOOL WINAPI SetSystemTime(const SYSTEMTIME *lpSystemTime);
    

    【讨论】:

      猜你喜欢
      • 2012-02-08
      • 2014-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多