将Windows SYSTEMTIME转换为C+中的字符串或字符buf+;与用户';s";“地区和语言”;格式? 我的C++程序是如何将用户首选的“长日期格式”中的系统时间转换为默认的语言设置,还是在控制面板上设置自定义设置> >区域和语言对话框?< /P> 如果我有问题,我在Visual Studio 2017上,主要寻找C/C++ 03类型的解决方案,但是如果有一个新C++的解决方案,我不介意看到它。 TCHAR buf[200]; GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &mysystime, NULL, buf, 200);

将Windows SYSTEMTIME转换为C+中的字符串或字符buf+;与用户';s";“地区和语言”;格式? 我的C++程序是如何将用户首选的“长日期格式”中的系统时间转换为默认的语言设置,还是在控制面板上设置自定义设置> >区域和语言对话框?< /P> 如果我有问题,我在Visual Studio 2017上,主要寻找C/C++ 03类型的解决方案,但是如果有一个新C++的解决方案,我不介意看到它。 TCHAR buf[200]; GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &mysystime, NULL, buf, 200);,c++,windows,internationalization,systemtime,C++,Windows,Internationalization,Systemtime,如果您还需要时间部分,也可以调用GetTimeFormat。时区信息tzi; TIME_ZONE_INFORMATION tzi; if ( GetTimeZoneInformation( &tzi ) == TIME_ZONE_ID_INVALID ) MyErrorFunction( "GetTimeZoneInformation() = TIME_ZONE_ID_INVALID : %s", GetLastErrorAsString().c_str() ); : :

如果您还需要时间部分,也可以调用
GetTimeFormat

时区信息tzi;
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.
if(GetTimeZoneInformation(&tzi)=时区ID无效) MyErrorFunction(“GetTimeZoneInformation()=时区ID无效:%s”, GetLastErrorAsString().c_str()); : : 系统时间st,stLocal; BOOL bRV=FileTimeToSystemTime(ftLastAccessTime,&st); SystemTimeToTsSpecificClocalTime(&tzi,&st,&stLocal); GetDateFormat(区域设置\用户\默认值、日期\长日期和stLocal、, 空,szBuf,sizeof(szBuf)); int=strlen(szBuf); if(小于sizeof(szBuf)-2) szBuf[i++]=''; GetTimeFormat(语言环境\用户\默认值、0和stLocal、, 空,szBuf+i融合,sizeof(szBuf)-i融合; //szBuf保存用户时区中的日期和时间,格式根据用户喜好而定。