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)
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 )
......
......@@ -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);
}
......
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