[PATCH 3/7] wbemprox: Add Organization property to Win32_Operatingsystem.

Louis Lenders xerox.xerox2000x at gmail.com
Tue Apr 26 01:41:25 CDT 2022


Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=52887
Signed-off-by: Louis Lenders <xerox.xerox2000x at gmail.com>
---
 dlls/wbemprox/builtin.c     | 23 +++++++++++++++++++++++
 dlls/wbemprox/tests/query.c |  1 +
 2 files changed, 24 insertions(+)

diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index 9f6b6f0efbe..405f71b8bd3 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -244,6 +244,7 @@ static const struct column col_operatingsystem[] =
     { L"Manufacturer",            CIM_STRING },
     { L"Name",                    CIM_STRING|COL_FLAG_DYNAMIC },
     { L"OperatingSystemSKU",      CIM_UINT32 },
+    { L"Organization",            CIM_STRING|COL_FLAG_DYNAMIC },
     { L"OSArchitecture",          CIM_STRING },
     { L"OSLanguage",              CIM_UINT32 },
     { L"OSProductSuite",          CIM_UINT32 },
@@ -673,6 +674,7 @@ struct record_operatingsystem
     const WCHAR *manufacturer;
     const WCHAR *name;
     UINT32       operatingsystemsku;
+    const WCHAR *organization;
     const WCHAR *osarchitecture;
     UINT32       oslanguage;
     UINT32       osproductsuite;
@@ -3503,6 +3505,26 @@ static WCHAR *get_locale(void)
     if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, ret, 5 );
     return ret;
 }
+static WCHAR *get_organization(void)
+{
+    HKEY hkey = 0;
+    DWORD size, type;
+    WCHAR *ret = NULL;
+
+    if (!RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hkey ) &&
+        !RegQueryValueExW( hkey, L"RegisteredOrganization", NULL, &type, NULL, &size ) && type == REG_SZ &&
+        (ret = malloc( size + sizeof(WCHAR) )))
+    {
+        size += sizeof(WCHAR);
+        if (RegQueryValueExW( hkey, L"RegisteredOrganization", NULL, NULL, (BYTE *)ret, &size ))
+        {
+            free( ret );
+            ret = NULL;
+        }
+    }
+    if (hkey) RegCloseKey( hkey );
+    return ret;
+}
 static WCHAR *get_osbuildnumber( OSVERSIONINFOEXW *ver )
 {
     WCHAR *ret = malloc( 11 * sizeof(WCHAR) );
@@ -3652,6 +3674,7 @@ static enum fill_status fill_operatingsystem( struct table *table, const struct
     rec->manufacturer           = L"The Wine Project";
     rec->name                   = get_osname( rec->caption );
     rec->operatingsystemsku     = get_operatingsystemsku();
+    rec->organization           = get_organization();
     rec->osarchitecture         = get_osarchitecture();
     rec->oslanguage             = GetSystemDefaultLangID();
     rec->osproductsuite         = 2461140; /* Windows XP Professional  */
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c
index e4a8a8d361b..0d2848f609f 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -1428,6 +1428,7 @@ static void test_Win32_OperatingSystem( IWbemServices *services )
     check_property( obj, L"CSName", VT_BSTR, CIM_STRING );
     check_property( obj, L"CurrentTimeZone", VT_I2, CIM_SINT16 );
     check_property( obj, L"Manufacturer", VT_BSTR, CIM_STRING );
+    check_property( obj, L"Organization", VT_BSTR, CIM_STRING );
     check_property( obj, L"OSType", VT_I4, CIM_UINT16 );
     check_property( obj, L"ProductType", VT_I4, CIM_UINT32 );
     check_property( obj, L"RegisteredUser", VT_BSTR, CIM_STRING );
-- 
2.36.0




More information about the wine-devel mailing list