Commit 08831b4a authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Set the USERNAME and COMPANYNAME properties when initializing a package.

parent 8321276c
......@@ -141,6 +141,9 @@ static VOID set_installer_properties(MSIPACKAGE *package)
DWORD verval;
WCHAR verstr[10], bufstr[20];
HDC dc;
LPWSTR check;
HKEY hkey;
LONG res;
static const WCHAR cszbs[]={'\\',0};
static const WCHAR CFF[] =
......@@ -210,6 +213,18 @@ static VOID set_installer_properties(MSIPACKAGE *package)
static const WCHAR szScreenFormat[] = {'%','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 szCurrentVersion[] = {
'S','O','F','T','W','A','R','E','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
};
static const WCHAR szRegisteredUser[] = {'R','e','g','i','s','t','e','r','e','d','O','w','n','e','r',0};
static const WCHAR szRegisteredOrg[] = {
'R','e','g','i','s','t','e','r','e','d','O','r','g','a','n','i','z','a','t','i','o','n',0
};
static const WCHAR szUSERNAME[] = {'U','S','E','R','N','A','M','E',0};
static const WCHAR szCOMPANYNAME[] = {'C','O','M','P','A','N','Y','N','A','M','E',0};
SYSTEM_INFO sys_info;
/*
......@@ -353,6 +368,32 @@ static VOID set_installer_properties(MSIPACKAGE *package)
sprintfW( bufstr, szScreenFormat, GetDeviceCaps( dc, BITSPIXEL ));
MSI_SetPropertyW( package, szColorBits, bufstr );
ReleaseDC(0, dc);
/* USERNAME and COMPANYNAME */
res = RegOpenKeyW( HKEY_LOCAL_MACHINE, szCurrentVersion, &hkey );
if (res != ERROR_SUCCESS)
return;
check = msi_dup_property( package, szUSERNAME );
if (!check)
{
LPWSTR user = msi_reg_get_val_str( hkey, szRegisteredUser );
MSI_SetPropertyW( package, szUSERNAME, user );
msi_free( user );
}
msi_free( check );
check = msi_dup_property( package, szCOMPANYNAME );
if (!check)
{
LPWSTR company = msi_reg_get_val_str( hkey, szRegisteredOrg );
MSI_SetPropertyW( package, szCOMPANYNAME, company );
msi_free( company );
}
msi_free( check );
CloseHandle( hkey );
}
static UINT msi_get_word_count( MSIPACKAGE *package )
......
......@@ -2706,7 +2706,8 @@ static void test_installprops(void)
MSIHANDLE hpkg, hdb;
CHAR path[MAX_PATH];
CHAR buf[MAX_PATH];
DWORD size;
DWORD size, type;
HKEY hkey;
UINT r;
GetCurrentDirectory(MAX_PATH, path);
......@@ -2725,7 +2726,30 @@ static void test_installprops(void)
r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
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);
size = MAX_PATH;
type = REG_SZ;
RegQueryValueEx(hkey, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
size = MAX_PATH;
r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
size = MAX_PATH;
type = REG_SZ;
RegQueryValueEx(hkey, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
size = MAX_PATH;
r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
CloseHandle(hkey);
MsiCloseHandle(hpkg);
DeleteFile(msifile);
}
static void test_sourcedirprop(void)
......
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