dxdiagn: Add date and time properties to the DxDiag_SystemInfo container.
authorAndrew Nguyen <anguyen@codeweavers.com>
Mon, 4 Apr 2011 01:55:53 +0000 (20:55 -0500)
committerAlexandre Julliard <julliard@winehq.org>
Mon, 4 Apr 2011 11:15:58 +0000 (13:15 +0200)
dlls/dxdiagn/provider.c
dlls/dxdiagn/tests/container.c

index 537db4ee01bc3690d568475734b6405679fd91cb..0004d0f06baa32beb7a628a6e4bc38b59f9e0e2f 100644 (file)
@@ -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;
 }
 
index 8df4cb30a34379b80c27cd36259951d266223d4b..6c6928cbbe0dd25ed7f61ba3bc7ebdf7e35dbd5d 100644 (file)
@@ -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;