【发布时间】:2011-10-29 07:04:43
【问题描述】:
我正在尝试使用 C++ 设置 Windows 系统时钟。 我正在尝试使用以下代码(不工作):
#include "stdafx.h"
#include "iostream"
#include "windows.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) {
SYSTEMTIME st;
st.wDay = 1;
st.wMonth = 5;
st.wYear = 2011;
st.wHour = 12;
st.wMinute = 15;
bool result = SetLocalTime(&st);
cout << result;
return 0;
}
有人能指出我的错误吗?提前致谢。
【问题讨论】:
-
根据the documentation,
SetLocalTime返回BOOL而不是bool。 -
@WTP 很好,它返回
BOOL,并标记为WINAPI(__stdcall)。它不返回WINAPI:) 另外,Mask,您需要说明如何您的代码不起作用,而不仅仅是它不起作用。 -
@Seth Carnegie 我从未使用过 Windows API。我只是阅读了文档。无论如何,谢谢你的信息。