Francois Gouget : msi: Use 'HKCU\Software\Microsoft\MS Setup (ACME)' as a source for the default user and company names before falling back to the RegisteredXXX values . Fix the conformance test accordingly.

Alexandre Julliard julliard at winehq.org
Tue Feb 19 08:05:16 CST 2008


Module: wine
Branch: master
Commit: 4a7bedfe756206756ff6c2eed09949913f651564
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4a7bedfe756206756ff6c2eed09949913f651564

Author: Francois Gouget <fgouget at free.fr>
Date:   Tue Feb 19 00:17:24 2008 +0100

msi: Use 'HKCU\Software\Microsoft\MS Setup (ACME)' as a source for the default user and company names before falling back to the RegisteredXXX values. Fix the conformance test accordingly.

---

 dlls/msi/package.c       |   52 +++++++++++++++++++++++++++------------------
 dlls/msi/tests/package.c |   23 ++++++++++++++++----
 2 files changed, 49 insertions(+), 26 deletions(-)

diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 685a28d..2ffbfb5 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -347,9 +347,8 @@ static VOID set_installer_properties(MSIPACKAGE *package)
     DWORD verval;
     WCHAR verstr[10], bufstr[20];
     HDC dc;
-    LPWSTR check;
     HKEY hkey;
-    LONG res;
+    LPWSTR username, companyname;
     SYSTEM_INFO sys_info;
     SYSTEMTIME systemtime;
     LANGID langid;
@@ -424,6 +423,14 @@ static VOID set_installer_properties(MSIPACKAGE *package)
     static const WCHAR szIntFormat[] = {'%','d',0};
     static const WCHAR szIntel[] = { 'I','n','t','e','l',0 };
     static const WCHAR szAllUsers[] = { 'A','L','L','U','S','E','R','S',0 };
+    static const WCHAR szUserInfo[] = {
+        'S','O','F','T','W','A','R','E','\\',
+        'M','i','c','r','o','s','o','f','t','\\',
+        'M','S',' ','S','e','t','u','p',' ','(','A','C','M','E',')','\\',
+        'U','s','e','r',' ','I','n','f','o',0
+    };
+    static const WCHAR szDefName[] = { 'D','e','f','N','a','m','e',0 };
+    static const WCHAR szDefCompany[] = { 'D','e','f','C','o','m','p','a','n','y',0 };
     static const WCHAR szCurrentVersion[] = {
         'S','O','F','T','W','A','R','E','\\',
         'M','i','c','r','o','s','o','f','t','\\',
@@ -587,27 +594,33 @@ static VOID set_installer_properties(MSIPACKAGE *package)
     ReleaseDC(0, dc);
 
     /* USERNAME and COMPANYNAME */
-    res = RegOpenKeyW( HKEY_LOCAL_MACHINE, szCurrentVersion, &hkey );
-    if (res != ERROR_SUCCESS)
-        return;
+    username = msi_dup_property( package, szUSERNAME );
+    companyname = msi_dup_property( package, szCOMPANYNAME );
 
-    check = msi_dup_property( package, szUSERNAME );
-    if (!check)
+    if ((!username || !companyname) &&
+        RegOpenKeyW( HKEY_CURRENT_USER, szUserInfo, &hkey ) == ERROR_SUCCESS)
     {
-        LPWSTR user = msi_reg_get_val_str( hkey, szRegisteredUser );
-        MSI_SetPropertyW( package, szUSERNAME, user );
-        msi_free( user );
+        if (!username &&
+            (username = msi_reg_get_val_str( hkey, szDefName )))
+            MSI_SetPropertyW( package, szUSERNAME, username );
+        if (!companyname &&
+            (companyname = msi_reg_get_val_str( hkey, szDefCompany )))
+            MSI_SetPropertyW( package, szCOMPANYNAME, companyname );
+        CloseHandle( hkey );
     }
-
-    msi_free( check );
-
-    check = msi_dup_property( package, szCOMPANYNAME );
-    if (!check)
+    if ((!username || !companyname) &&
+        RegOpenKeyW( HKEY_LOCAL_MACHINE, szCurrentVersion, &hkey ) == ERROR_SUCCESS)
     {
-        LPWSTR company = msi_reg_get_val_str( hkey, szRegisteredOrg );
-        MSI_SetPropertyW( package, szCOMPANYNAME, company );
-        msi_free( company );
+        if (!username &&
+            (username = msi_reg_get_val_str( hkey, szRegisteredUser )))
+            MSI_SetPropertyW( package, szUSERNAME, username );
+        if (!companyname &&
+            (companyname = msi_reg_get_val_str( hkey, szRegisteredOrg )))
+            MSI_SetPropertyW( package, szCOMPANYNAME, companyname );
+        CloseHandle( hkey );
     }
+    msi_free( username );
+    msi_free( companyname );
 
     if ( set_user_sid_prop( package ) != ERROR_SUCCESS)
         ERR("Failed to set the UserSID property\n");
@@ -634,9 +647,6 @@ static VOID set_installer_properties(MSIPACKAGE *package)
     sprintfW(bufstr, szIntFormat, langid);
 
     MSI_SetPropertyW( package, szUserLangID, bufstr );
-
-    msi_free( check );
-    CloseHandle( hkey );
 }
 
 static UINT msi_load_summary_properties( MSIPACKAGE *package )
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index 9d1f8b8..3d50a8f 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -4698,7 +4698,7 @@ static void test_installprops(void)
     CHAR buf[MAX_PATH];
     DWORD size, type;
     LANGID langid;
-    HKEY hkey;
+    HKEY hkey1, hkey2;
     UINT r;
 
     GetCurrentDirectory(MAX_PATH, path);
@@ -4718,11 +4718,18 @@ static void test_installprops(void)
     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
 
-    RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey);
+    RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
+
+    RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey2);
 
     size = MAX_PATH;
     type = REG_SZ;
-    RegQueryValueEx(hkey, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
+    if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
+    {
+        size = MAX_PATH;
+        type = REG_SZ;
+        RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
+    }
 
     size = MAX_PATH;
     r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
@@ -4731,7 +4738,12 @@ static void test_installprops(void)
 
     size = MAX_PATH;
     type = REG_SZ;
-    RegQueryValueEx(hkey, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
+    if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
+    {
+        size = MAX_PATH;
+        type = REG_SZ;
+        RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
+    }
 
     size = MAX_PATH;
     r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
@@ -4771,7 +4783,8 @@ static void test_installprops(void)
     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
 
-    CloseHandle(hkey);
+    CloseHandle(hkey1);
+    CloseHandle(hkey2);
     MsiCloseHandle(hpkg);
     DeleteFile(msifile);
 }




More information about the wine-cvs mailing list