From bd7ad13bb38a31136c671bbc739fb8fa3c3d6515 Mon Sep 17 00:00:00 2001 From: Andrew Nguyen Date: Sun, 3 Apr 2011 20:55:53 -0500 Subject: [PATCH] dxdiagn: Add date and time properties to the DxDiag_SystemInfo container. --- dlls/dxdiagn/provider.c | 41 ++++++++++++++++++++++++++++++++++ dlls/dxdiagn/tests/container.c | 4 ++++ 2 files changed, 45 insertions(+) diff --git a/dlls/dxdiagn/provider.c b/dlls/dxdiagn/provider.c index 537db4ee01..0004d0f06b 100644 --- a/dlls/dxdiagn/provider.c +++ b/dlls/dxdiagn/provider.c @@ -474,6 +474,43 @@ static HRESULT fill_language_information(IDxDiagContainerImpl_Container *node) return S_OK; } +static HRESULT fill_datetime_information(IDxDiagContainerImpl_Container *node) +{ + static const WCHAR date_fmtW[] = {'M','\'','/','\'','d','\'','/','\'','y','y','y','y',0}; + static const WCHAR time_fmtW[] = {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0}; + static const WCHAR datetime_fmtW[] = {'%','s',',',' ','%','s',0}; + static const WCHAR szTimeLocalized[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0}; + static const WCHAR szTimeEnglish[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0}; + + SYSTEMTIME curtime; + WCHAR date_str[80], time_str[80], datetime_str[200]; + HRESULT hr; + + GetLocalTime(&curtime); + + GetTimeFormatW(LOCALE_NEUTRAL, 0, &curtime, time_fmtW, time_str, sizeof(time_str)/sizeof(WCHAR)); + + /* szTimeLocalized */ + GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &curtime, NULL, date_str, sizeof(date_str)/sizeof(WCHAR)); + + snprintfW(datetime_str, sizeof(datetime_str)/sizeof(WCHAR), datetime_fmtW, date_str, time_str); + + hr = add_bstr_property(node, szTimeLocalized, datetime_str); + if (FAILED(hr)) + return hr; + + /* szTimeEnglish */ + GetDateFormatW(LOCALE_NEUTRAL, 0, &curtime, date_fmtW, date_str, sizeof(date_str)/sizeof(WCHAR)); + + snprintfW(datetime_str, sizeof(datetime_str)/sizeof(WCHAR), datetime_fmtW, date_str, time_str); + + hr = add_bstr_property(node, szTimeEnglish, datetime_str); + if (FAILED(hr)) + return hr; + + return S_OK; +} + static HRESULT build_systeminfo_tree(IDxDiagContainerImpl_Container *node) { static const WCHAR dwDirectXVersionMajor[] = {'d','w','D','i','r','e','c','t','X','V','e','r','s','i','o','n','M','a','j','o','r',0}; @@ -597,6 +634,10 @@ static HRESULT build_systeminfo_tree(IDxDiagContainerImpl_Container *node) if (FAILED(hr)) return hr; + hr = fill_datetime_information(node); + if (FAILED(hr)) + return hr; + return S_OK; } diff --git a/dlls/dxdiagn/tests/container.c b/dlls/dxdiagn/tests/container.c index 8df4cb30a3..6c6928cbbe 100644 --- a/dlls/dxdiagn/tests/container.c +++ b/dlls/dxdiagn/tests/container.c @@ -786,6 +786,8 @@ static void test_DxDiag_SystemInfo(void) static const WCHAR szMachineNameEnglish[] = {'s','z','M','a','c','h','i','n','e','N','a','m','e','E','n','g','l','i','s','h',0}; static const WCHAR szLanguagesLocalized[] = {'s','z','L','a','n','g','u','a','g','e','s','L','o','c','a','l','i','z','e','d',0}; static const WCHAR szLanguagesEnglish[] = {'s','z','L','a','n','g','u','a','g','e','s','E','n','g','l','i','s','h',0}; + static const WCHAR szTimeLocalized[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0}; + static const WCHAR szTimeEnglish[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0}; static const struct { @@ -814,6 +816,8 @@ static void test_DxDiag_SystemInfo(void) {szMachineNameEnglish, VT_BSTR}, {szLanguagesLocalized, VT_BSTR}, {szLanguagesEnglish, VT_BSTR}, + {szTimeLocalized, VT_BSTR}, + {szTimeEnglish, VT_BSTR}, }; HRESULT hr;