gpt4 book ai didi

c - 从 FileTimeToSystemTime() 获取错误的值?为什么?

转载 作者:行者123 更新时间:2023-11-30 20:49:18 25 4
gpt4 key购买 nike

FILETIME Kernel_Time;
HANDLE Process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, 0);
GetProcessTimes(Process, NULL, NULL, &Kernel_Time, NULL);
SYSTEMTIME Sys_Time;
FileTimeToSystemTime(&Kernel_Time, &Sys_Time);
printf("%d", Sys_Time.wYear); // WHY ?

为什么 Sys_Time.wYear 不是 2013 年?

有人可以帮助我吗?

最佳答案

HANDLE Process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, 0);

根据 documentation ,

If the specified process is the System Process (0x00000000), the function fails and the last error code is ERROR_INVALID_PARAMETER.

因此,您的 OpenProcess 失败并显示 ERROR_INVALID_PARAMETER,并且 HANDLE ProcessNULL。请务必检查故障条件和相应的错误代码。

话又说回来,GetProcessTimes API 参数不是可选的,因此您不应将 NULL 传递给它们,而应将指向 FILETIME 结构的指针传递给它们。

关于c - 从 FileTimeToSystemTime() 获取错误的值?为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20041106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com