使用用户的 "Region and Language" 格式将 Windows SYSTEMTIME 转换为 C++ 中的字符串或字符 buf?

convert Windows SYSTEMTIME to a string or char buf in C++ with user's "Region and Language" format?

我的 C++ 程序如何将 SYSTEMTIME 转换为用户首选 "long date format" 中的默认语言设置,或者在“控制面板”->“区域和语言”对话框中自定义设置?

如果这很重要,我在 Visual Studio 2017 年,主要寻找 C/C++03 类型的解决方案,但如果有更新的 C++ 的解决方案,我不介意看到它。

TCHAR buf[200];
GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &mysystime, NULL, buf, 200);

如果您还需要时间部分,也可以致电GetTimeFormat

TIME_ZONE_INFORMATION tzi;
if ( GetTimeZoneInformation( &tzi ) == TIME_ZONE_ID_INVALID )
MyErrorFunction( "GetTimeZoneInformation() = TIME_ZONE_ID_INVALID : %s",
    GetLastErrorAsString().c_str() );
  :
  :

SYSTEMTIME st, stLocal;
BOOL bRV = FileTimeToSystemTime( ftLastAccessTime, &st );
SystemTimeToTzSpecificLocalTime( &tzi, &st, &stLocal );

GetDateFormat( LOCALE_USER_DEFAULT, DATE_LONGDATE, &stLocal,
               NULL, szBuf, sizeof( szBuf ) );

int iBufUsed = strlen( szBuf );
if ( iBufUsed < sizeof( szBuf ) - 2 )
     szBuf[ iBufUsed++ ] = ' ';

GetTimeFormat( LOCALE_USER_DEFAULT, 0, &stLocal,
               NULL, szBuf + iBufUsed, sizeof( szBuf ) - iBufUsed );

// szBuf holds Date and Time, in the user's timezone, formatted as the user prefers.