将Windows SYSTEMTIME转换为字符串或字符buf,C++与用户的"Region and Language"格式?
convert Windows SYSTEMTIME to a string or char buf in C++ with user's "Region and Language" format?
我的C 程序如何在用户首选的"长期格式"中转换一个从其语言设置默认的" 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.
相关文章:
- C++如何通过用户输入删除列表元素
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- 如何使用用户输入在C++中正确填充2D数组
- C++MySQL C api用户输入行
- 使用用户定义函数的字符串反转
- 用户定义函数中的指针和输入
- 为什么即使使用-cudart-static进行编译,库用户仍然需要链接到cuda运行时
- 如何只允许用户输入正整数
- C++如何计算用户输入的数字中的偶数位数
- 通过for循环使用用户输入填充列表
- 这是我尝试让用户将值输入到数组中.然后将其隐藏为大量的星号
- 在C++中,我如何接受不同于同一行的用户输入
- 当用户超过按钮点击限制时报告
- Visual C++(VS2017)中用户定义的转换不明确
- 如果用户输入无效,如何使用字符串变量-C++重复输入命令
- C++问题:用户认为数字1-100,程序提出问题不超过6次即可得到答案。无法正确
- 当用户键入分隔符时,停止getline()输入
- 通过错误处理,在C++中可靠地获得用户十六进制输入
- RegGetValue在当前用户下找不到名称
- 将Windows SYSTEMTIME转换为字符串或字符buf,C++与用户的"Region and Language"格式?