-
StackOverflow 文件
-
uwp 教程
-
如何在 C ++ UWP 中獲取當前的 DateTime
-
GetCurrentDateTime()
#include <windows.h>
static Windows::Foundation::DateTime GetCurrentDateTime() {
// Get the current system time
SYSTEMTIME st;
GetSystemTime(&st);
// Convert it to something DateTime will understand
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
// Conversion to DateTime's long long is done vie ULARGE_INTEGER
ULARGE_INTEGER ui;
ui.LowPart = ft.dwLowDateTime;
ui.HighPart = ft.dwHighDateTime;
DateTime currentDateTime;
currentDateTime.UniversalTime = ui.QuadPart;
return currentDateTime;
}