Commit 4a7bedfe authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

msi: Use 'HKCU\Software\Microsoft\MS Setup (ACME)' as a source for the default…

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.
parent e9a8e6a4
...@@ -347,9 +347,8 @@ static VOID set_installer_properties(MSIPACKAGE *package) ...@@ -347,9 +347,8 @@ static VOID set_installer_properties(MSIPACKAGE *package)
DWORD verval; DWORD verval;
WCHAR verstr[10], bufstr[20]; WCHAR verstr[10], bufstr[20];
HDC dc; HDC dc;
LPWSTR check;
HKEY hkey; HKEY hkey;
LONG res; LPWSTR username, companyname;
SYSTEM_INFO sys_info; SYSTEM_INFO sys_info;
SYSTEMTIME systemtime; SYSTEMTIME systemtime;
LANGID langid; LANGID langid;
...@@ -424,6 +423,14 @@ static VOID set_installer_properties(MSIPACKAGE *package) ...@@ -424,6 +423,14 @@ static VOID set_installer_properties(MSIPACKAGE *package)
static const WCHAR szIntFormat[] = {'%','d',0}; static const WCHAR szIntFormat[] = {'%','d',0};
static const WCHAR szIntel[] = { 'I','n','t','e','l',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 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[] = { static const WCHAR szCurrentVersion[] = {
'S','O','F','T','W','A','R','E','\\', 'S','O','F','T','W','A','R','E','\\',
'M','i','c','r','o','s','o','f','t','\\', 'M','i','c','r','o','s','o','f','t','\\',
...@@ -587,27 +594,33 @@ static VOID set_installer_properties(MSIPACKAGE *package) ...@@ -587,27 +594,33 @@ static VOID set_installer_properties(MSIPACKAGE *package)
ReleaseDC(0, dc); ReleaseDC(0, dc);
/* USERNAME and COMPANYNAME */ /* USERNAME and COMPANYNAME */
res = RegOpenKeyW( HKEY_LOCAL_MACHINE, szCurrentVersion, &hkey ); username = msi_dup_property( package, szUSERNAME );
if (res != ERROR_SUCCESS) companyname = msi_dup_property( package, szCOMPANYNAME );
return;
check = msi_dup_property( package, szUSERNAME ); if ((!username || !companyname) &&
if (!check) RegOpenKeyW( HKEY_CURRENT_USER, szUserInfo, &hkey ) == ERROR_SUCCESS)
{ {
LPWSTR user = msi_reg_get_val_str( hkey, szRegisteredUser ); if (!username &&
MSI_SetPropertyW( package, szUSERNAME, user ); (username = msi_reg_get_val_str( hkey, szDefName )))
msi_free( user ); MSI_SetPropertyW( package, szUSERNAME, username );
if (!companyname &&
(companyname = msi_reg_get_val_str( hkey, szDefCompany )))
MSI_SetPropertyW( package, szCOMPANYNAME, companyname );
CloseHandle( hkey );
} }
if ((!username || !companyname) &&
msi_free( check ); RegOpenKeyW( HKEY_LOCAL_MACHINE, szCurrentVersion, &hkey ) == ERROR_SUCCESS)
check = msi_dup_property( package, szCOMPANYNAME );
if (!check)
{ {
LPWSTR company = msi_reg_get_val_str( hkey, szRegisteredOrg ); if (!username &&
MSI_SetPropertyW( package, szCOMPANYNAME, company ); (username = msi_reg_get_val_str( hkey, szRegisteredUser )))
msi_free( company ); 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) if ( set_user_sid_prop( package ) != ERROR_SUCCESS)
ERR("Failed to set the UserSID property\n"); ERR("Failed to set the UserSID property\n");
...@@ -634,9 +647,6 @@ static VOID set_installer_properties(MSIPACKAGE *package) ...@@ -634,9 +647,6 @@ static VOID set_installer_properties(MSIPACKAGE *package)
sprintfW(bufstr, szIntFormat, langid); sprintfW(bufstr, szIntFormat, langid);
MSI_SetPropertyW( package, szUserLangID, bufstr ); MSI_SetPropertyW( package, szUserLangID, bufstr );
msi_free( check );
CloseHandle( hkey );
} }
static UINT msi_load_summary_properties( MSIPACKAGE *package ) static UINT msi_load_summary_properties( MSIPACKAGE *package )
......
...@@ -4698,7 +4698,7 @@ static void test_installprops(void) ...@@ -4698,7 +4698,7 @@ static void test_installprops(void)
CHAR buf[MAX_PATH]; CHAR buf[MAX_PATH];
DWORD size, type; DWORD size, type;
LANGID langid; LANGID langid;
HKEY hkey; HKEY hkey1, hkey2;
UINT r; UINT r;
GetCurrentDirectory(MAX_PATH, path); GetCurrentDirectory(MAX_PATH, path);
...@@ -4718,11 +4718,18 @@ static void test_installprops(void) ...@@ -4718,11 +4718,18 @@ static void test_installprops(void)
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r); ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf); 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; size = MAX_PATH;
type = REG_SZ; 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; size = MAX_PATH;
r = MsiGetProperty(hpkg, "USERNAME", buf, &size); r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
...@@ -4731,7 +4738,12 @@ static void test_installprops(void) ...@@ -4731,7 +4738,12 @@ static void test_installprops(void)
size = MAX_PATH; size = MAX_PATH;
type = REG_SZ; 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; size = MAX_PATH;
r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size); r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
...@@ -4771,7 +4783,8 @@ static void test_installprops(void) ...@@ -4771,7 +4783,8 @@ static void test_installprops(void)
ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r); ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf); ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
CloseHandle(hkey); CloseHandle(hkey1);
CloseHandle(hkey2);
MsiCloseHandle(hpkg); MsiCloseHandle(hpkg);
DeleteFile(msifile); DeleteFile(msifile);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment