[英]How Get Start Day of Week?
I have adjusted the first day of week at Region and Local settings in a control panel (Windows 7), and now I'm writing a C++ function that must returns the first day of week which I have adjusted. 我已经在控制面板(Windows 7)中的“区域”和“本地”设置中调整了一周的第一天,现在我正在编写一个C ++函数,该函数必须返回已调整的一周的第一天。 Any Windows API or standard c++ function that I can use it ? 我可以使用任何Windows API或标准c ++函数吗?
(Sorry what I had written was totally wrong. I have updated the post.) (对不起,我写的是完全错误的。我已经更新了帖子。)
The right function to use is EnumCalendarInfoExEx : 正确使用的函数是EnumCalendarInfoExEx :
#include <Windows.h>
#include <strsafe.h>
#include <iostream>
using namespace std;
BOOL CALLBACK EnumCalendarInfoProcExEx(LPWSTR lpszInfo, CALID calendar, LPWSTR lpReserved, LPARAM lParam)
{
StringCchCopy(reinterpret_cast<LPWSTR>(lParam), 64, lpszInfo);
return FALSE;
}
int main()
{
WCHAR szDay[64];
BOOL bResult = ::EnumCalendarInfoExEx(
&EnumCalendarInfoProcExEx,
LOCALE_NAME_USER_DEFAULT,
ENUM_ALL_CALENDARS,
nullptr,
CAL_SDAYNAME1,
reinterpret_cast<LPARAM>(szDay)
);
if (!bResult)
{
wcout << L"Error" << endl;
return 0;
}
wcout << szDay << endl;
return 0;
}
A couple of things to watch out for: 需要注意的几件事:
I try use a GetLocaleInfoEx windows API and it worked well :) 我尝试使用GetLocaleInfoEx Windows API,它运行良好:)
int GetSystemStartDayOfWeek()
{
int ret;
DWORD StartDayOfWeek;
ret = GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT,
LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER,
(LPTSTR)&StartDayOfWeek,
sizeof(StartDayOfWeek) / sizeof(TCHAR));
return StartDayOfWeek;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.