From 828280f4fd9b54c22593e891429fcbe7d21035a0 Mon Sep 17 00:00:00 2001 From: Mike McCormack <mike@codeweavers.com> Date: Tue, 15 Nov 2005 12:00:13 +0000 Subject: [PATCH] Set the Installed property if the product is already installed. --- dlls/msi/package.c | 73 +++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/dlls/msi/package.c b/dlls/msi/package.c index 68caa2076ce..96bf46fc089 100644 --- a/dlls/msi/package.c +++ b/dlls/msi/package.c @@ -31,7 +31,6 @@ #include "wine/debug.h" #include "msi.h" #include "msiquery.h" -#include "msipriv.h" #include "objidl.h" #include "wincrypt.h" #include "winuser.h" @@ -39,6 +38,9 @@ #include "wine/unicode.h" #include "objbase.h" +#include "msipriv.h" +#include "action.h" + WINE_DEFAULT_DEBUG_CHANNEL(msi); static void MSI_FreePackage( MSIOBJECTHDR *arg) @@ -120,6 +122,30 @@ static UINT clone_properties(MSIDATABASE *db) return rc; } +/* + * set_installed_prop + * + * Sets the "Installed" property to indicate that + * the product is installed for the current user. + */ +static UINT set_installed_prop( MSIPACKAGE *package ) +{ + static const WCHAR szInstalled[] = { + 'I','n','s','t','a','l','l','e','d',0 }; + WCHAR val[2] = { '1', 0 }; + HKEY hkey = 0; + UINT r; + + r = MSIREG_OpenUninstallKey( package->ProductCode, &hkey, FALSE ); + if (r == ERROR_SUCCESS) + { + RegCloseKey( hkey ); + MSI_SetPropertyW( package, szInstalled, val ); + } + + return r; +} + /* * There are a whole slew of these we need to set * @@ -203,29 +229,14 @@ static VOID set_installer_properties(MSIPACKAGE *package) static const WCHAR szColorBits[] = {'C','o','l','o','r','B','i','t','s',0}; static const WCHAR szScreenFormat[] = {'%','d',0}; -/* - * Other things I notice set - * -SystemLanguageID -ComputerName -UserLanguageID -LogonUser -VirtualMemory -Intel -ShellAdvSupport -DefaultUIFont -VersionDatabase -PackagecodeChanging -ProductState -CaptionHeight -BorderTop -BorderSide -TextHeight -RedirectedDllSupport -Time -Date -Privileged -*/ + /* + * Other things that probably should be set: + * + * SystemLanguageID ComputerName UserLanguageID LogonUser VirtualMemory + * Intel ShellAdvSupport DefaultUIFont VersionDatabase PackagecodeChanging + * ProductState CaptionHeight BorderTop BorderSide TextHeight + * RedirectedDllSupport Time Date Privileged + */ SHGetFolderPathW(NULL,CSIDL_PROGRAM_FILES_COMMON,NULL,0,pth); strcatW(pth,cszbs); @@ -357,6 +368,8 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db ) { static const WCHAR szLevel[] = { 'U','I','L','e','v','e','l',0 }; static const WCHAR szpi[] = {'%','i',0}; + static const WCHAR szProductCode[] = { + 'P','r','o','d','u','c','t','C','o','d','e',0}; MSIPACKAGE *package = NULL; WCHAR uilevel[10]; @@ -393,6 +406,9 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db ) set_installer_properties(package); sprintfW(uilevel,szpi,gUILevel); MSI_SetPropertyW(package, szLevel, uilevel); + + package->ProductCode = msi_dup_property( package, szProductCode ); + set_installed_prop( package ); } return package; @@ -431,8 +447,6 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage) MSIDATABASE *db = NULL; MSIPACKAGE *package; MSIHANDLE handle; - DWORD size; - static const WCHAR szProductCode[]= {'P','r','o','d','u','c','t','C','o','d','e',0}; UINT r; TRACE("%s %p\n", debugstr_w(szPackage), pPackage); @@ -478,13 +492,6 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage) MSI_SetPropertyW( package, Database, szPackage ); } - /* this property must exist */ - size = 0; - MSI_GetPropertyW(package,szProductCode,NULL,&size); - size ++; - package->ProductCode = msi_alloc(size * sizeof(WCHAR)); - MSI_GetPropertyW(package,szProductCode,package->ProductCode, &size); - *pPackage = package; return ERROR_SUCCESS; -- GitLab