Rob Shearman : msi: Set the Date, Time and VersionDatabase properties.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Mar 5 13:10:22 CST 2007
Module: wine
Branch: master
Commit: 95f38b75fbf7f25c317d1b18762aa982904d7ef4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=95f38b75fbf7f25c317d1b18762aa982904d7ef4
Author: Rob Shearman <rob at codeweavers.com>
Date: Mon Mar 5 12:03:20 2007 +0000
msi: Set the Date, Time and VersionDatabase properties.
Add tests for these properties.
Update the todo list of properties to set.
---
dlls/msi/package.c | 28 +++++++++++++++++++++++++---
dlls/msi/tests/package.c | 20 ++++++++++++++++++++
2 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index b78910d..74d18cb 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -182,6 +182,8 @@ static VOID set_installer_properties(MSIPACKAGE *package)
LPWSTR check;
HKEY hkey;
LONG res;
+ SYSTEM_INFO sys_info;
+ SYSTEMTIME systemtime;
static const WCHAR cszbs[]={'\\',0};
static const WCHAR CFF[] =
@@ -242,6 +244,7 @@ static VOID set_installer_properties(MSIPACKAGE *package)
static const WCHAR szSix[] = {'6',0 };
static const WCHAR szVersionMsi[] = { 'V','e','r','s','i','o','n','M','s','i',0 };
+ static const WCHAR szVersionDatabase[] = { 'V','e','r','s','i','o','n','D','a','t','a','b','a','s','e',0 };
static const WCHAR szPhysicalMemory[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 };
static const WCHAR szFormat2[] = {'%','l','i','.','%','l','i',0};
/* Screen properties */
@@ -263,15 +266,16 @@ static VOID set_installer_properties(MSIPACKAGE *package)
};
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;
+ static const WCHAR szDate[] = {'D','a','t','e',0};
+ static const WCHAR szTime[] = {'T','i','m','e',0};
/*
* Other things that probably should be set:
*
* SystemLanguageID ComputerName UserLanguageID LogonUser VirtualMemory
- * Intel ShellAdvSupport DefaultUIFont VersionDatabase PackagecodeChanging
+ * ShellAdvSupport DefaultUIFont PackagecodeChanging
* ProductState CaptionHeight BorderTop BorderSide TextHeight
- * RedirectedDllSupport Time Date Privileged
+ * RedirectedDllSupport
*/
SHGetFolderPathW(NULL,CSIDL_PROGRAM_FILES_COMMON,NULL,0,pth);
@@ -389,6 +393,8 @@ static VOID set_installer_properties(MSIPACKAGE *package)
sprintfW( bufstr, szFormat2, MSI_MAJORVERSION, MSI_MINORVERSION);
MSI_SetPropertyW( package, szVersionMsi, bufstr );
+ sprintfW( bufstr, szFormat, MSI_MAJORVERSION * 100);
+ MSI_SetPropertyW( package, szVersionDatabase, bufstr );
GetSystemInfo( &sys_info );
if (sys_info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
@@ -433,6 +439,22 @@ static VOID set_installer_properties(MSIPACKAGE *package)
if ( set_user_sid_prop( package ) != ERROR_SUCCESS)
ERR("Failed to set the UserSID property\n");
+ /* Date and time properties */
+ GetSystemTime( &systemtime );
+ if (GetDateFormatW( LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systemtime,
+ NULL, bufstr, sizeof(bufstr)/sizeof(bufstr[0]) ))
+ MSI_SetPropertyW( package, szDate, bufstr );
+ else
+ ERR("Couldn't set Date property: GetDateFormat failed with error %d\n", GetLastError());
+
+ if (GetTimeFormatW( LOCALE_USER_DEFAULT,
+ TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER,
+ &systemtime, NULL, bufstr,
+ sizeof(bufstr)/sizeof(bufstr[0]) ))
+ MSI_SetPropertyW( package, szTime, bufstr );
+ else
+ ERR("Couldn't set Time property: GetTimeFormat failed with error %d\n", GetLastError());
+
msi_free( check );
CloseHandle( hkey );
}
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index 233b472..536fa1e 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -2998,6 +2998,26 @@ 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);
+ size = MAX_PATH;
+ r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
+ ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
+ trace("VersionDatabase = %s\n", buf);
+
+ size = MAX_PATH;
+ r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
+ ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
+ trace("VersionMsi = %s\n", buf);
+
+ size = MAX_PATH;
+ r = MsiGetProperty(hpkg, "Date", buf, &size);
+ ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
+ trace("Date = %s\n", buf);
+
+ size = MAX_PATH;
+ r = MsiGetProperty(hpkg, "Time", buf, &size);
+ ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
+ trace("Time = %s\n", buf);
+
CloseHandle(hkey);
MsiCloseHandle(hpkg);
DeleteFile(msifile);
More information about the wine-cvs
mailing list