如何填充 SYSTEMTIME 值?

发布于 2024-07-08 12:07:24 字数 336 浏览 5 评论 0原文

在 Windows Mobile 上(但我想在 Windows 上也是一样),在本机 C++ 应用程序中,我将如何正确设置 SYSTEMTIME 结构? 假设我

int year, month, dayOfMonth, hour, minute, second;

显然应该设置 SYSTEMTIME 结构的 wHour、wYear 等成员,但是在这种情况下 wDayOfWeek 会发生什么,我宁愿也正确设置它。 我已经查看过,但没有在 MSDN 中找到任何允许我填充 SYSTEMTIME 结构的函数,其中将为我计算 wDayOfWeek 成员。 我错过了什么或者我该怎么做?

On Windows Mobile (but I guess it's the same on Windows) in a native C++ app, how would I go about setting a SYSTEMTIME structure correctly? Assuming I have

int year, month, dayOfMonth, hour, minute, second;

I obviously should set the wHour, wYear, etc members of the SYSTEMTIME structure, but what happens with wDayOfWeek in that case, I would rather have this set up correctly as well. I have looked but not found any functions in MSDN that would allow me to populate a SYSTEMTIME structure where the wDayOfWeek member would be calculated for me. Did I miss something or how would I go about that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

年华零落成诗 2024-07-15 12:07:24

您可以填写您知道的字段,然后转换为变体时间并返回。

这可能会填补缺失的数据。

You could fill in the fields you know, then convert to variant time and back.

That might fill in the missing data.

风尘浪孓 2024-07-15 12:07:24

嗯...

也许先构造一个 FILETIME 然后调用 FileTimeToSystemTime ?

有关 FILETIME 的信息
http://msdn.microsoft.com/en-us /library/ms724284(VS.85).aspx

或者,首先构造 VT_TIME 的 VARIANT,然后调用 VariantTimeToSystemTime。
http://msdn.microsoft.com/en-us/library/ms221440。 ASPX

Hmm...

Maybe first construct a FILETIME and then call FileTimeToSystemTime?

Info on FILETIME
http://msdn.microsoft.com/en-us/library/ms724284(VS.85).aspx

Or, first contruct a VARIANT of VT_TIME and then callVariantTimeToSystemTime.
http://msdn.microsoft.com/en-us/library/ms221440.aspx

夏天碎花小短裙 2024-07-15 12:07:24

一些谷歌搜索发现你需要使用世界末日规则来解决这个问题。
下面的链接中有一些 C++ 示例和更多信息。

但真正的解决方案取决于您的日期和从哪里获得。
就像其他人所说的那样,将其转换为文件时间然后生成系统时间可能更容易。

Some googling turns up that you need to use the doomsday rule to figure this out.
There are some c++ examples and further information in the links below.

But the real solution depends on what date you have and where you get it from.
Like the others have said it may be easier to turn it into a filetime and then generate the systemtime.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文