From e2511e195e852d709848345384f9eb00ad8debf1 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sun, 29 May 2005 20:17:30 +0000 Subject: [PATCH] Added VarMonthName() implementation. --- dlls/oleaut32/oleaut32.spec | 2 +- dlls/oleaut32/varformat.c | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/dlls/oleaut32/oleaut32.spec b/dlls/oleaut32/oleaut32.spec index f8ead25543e..83b3c349d6d 100644 --- a/dlls/oleaut32/oleaut32.spec +++ b/dlls/oleaut32/oleaut32.spec @@ -126,7 +126,7 @@ 126 stdcall VarBoolFromDisp(ptr long ptr) 127 stdcall VarFormatCurrency(ptr long long long long long ptr) 128 stub VarWeekdayName # stdcall (long long long long ptr) -129 stub VarMonthName # stdcall (long long long ptr) +129 stdcall VarMonthName(long long long ptr) 130 stdcall VarUI1FromI2(long ptr) 131 stdcall VarUI1FromI4(long ptr) 132 stdcall VarUI1FromR4(long ptr) diff --git a/dlls/oleaut32/varformat.c b/dlls/oleaut32/varformat.c index 32770f8e5cf..3a6c130d793 100644 --- a/dlls/oleaut32/varformat.c +++ b/dlls/oleaut32/varformat.c @@ -2405,3 +2405,57 @@ HRESULT WINAPI VarFormatCurrency(LPVARIANT pVarIn, INT nDigits, INT nLeading, } return hRet; } + +/********************************************************************** + * VarMonthName [OLEAUT32.129] + * + * Print the specified month as localized name. + * + * PARAMS + * iMonth [I] month number 1..12 + * fAbbrev [I] 0 - full name, !0 - abbreviated name + * dwFlags [I] flag stuff. only VAR_CALENDAR_HIJRI possible. + * pbstrOut [O] Destination for month name + * + * RETURNS + * Success: S_OK. pbstrOut contains the name. + * Failure: E_INVALIDARG, if any parameter is invalid. + * E_OUTOFMEMORY, if enough memory cannot be allocated. + */ +HRESULT WINAPI VarMonthName(INT iMonth, INT fAbbrev, ULONG dwFlags, BSTR *pbstrOut) +{ + DWORD localeValue; + INT size; + WCHAR *str; + + if ((iMonth < 1) || (iMonth > 12)) + return E_INVALIDARG; + + if (dwFlags) + FIXME("Does not support dwFlags 0x%lx, ignoring.\n", dwFlags); + + if (fAbbrev) + localeValue = LOCALE_SABBREVMONTHNAME1 + iMonth - 1; + else + localeValue = LOCALE_SMONTHNAME1 + iMonth - 1; + + size = GetLocaleInfoW(LOCALE_USER_DEFAULT,localeValue, NULL, 0); + if (!size) { + FIXME("GetLocaleInfo 0x%lx failed.\n", localeValue); + return E_INVALIDARG; + } + str = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*size); + if (!str) + return E_OUTOFMEMORY; + size = GetLocaleInfoW(LOCALE_USER_DEFAULT,localeValue, str, size); + if (!size) { + FIXME("GetLocaleInfo of 0x%lx failed in 2nd stage?!\n", localeValue); + HeapFree(GetProcessHeap(),0,str); + return E_INVALIDARG; + } + *pbstrOut = SysAllocString(str); + HeapFree(GetProcessHeap(),0,str); + if (!*pbstrOut) + return E_OUTOFMEMORY; + return S_OK; +}