Commit 230af9d2 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

msi: Move version string conversions to registry.c.

parent 99172508
......@@ -3088,7 +3088,7 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
buffer = msi_dup_property( package, szProductVersion );
if (buffer)
{
DWORD verdword = build_version_dword(buffer);
DWORD verdword = msi_version_str_to_dword(buffer);
msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONW, verdword );
}
msi_free(buffer);
......@@ -3588,7 +3588,7 @@ static UINT ACTION_RegisterProduct(MSIPACKAGE *package)
buffer = msi_dup_property( package, szProductVersion );
if (buffer)
{
DWORD verdword = build_version_dword(buffer);
DWORD verdword = msi_version_str_to_dword(buffer);
msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONW, verdword );
msi_reg_set_val_dword( hkey, INSTALLPROPERTY_VERSIONMAJORW, verdword>>24 );
......
......@@ -266,7 +266,6 @@ extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
extern int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path);
extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
extern DWORD build_version_dword(LPCWSTR);
extern LPWSTR build_directory_name(DWORD , ...);
extern BOOL create_full_pathW(const WCHAR *path);
extern BOOL ACTION_VerifyComponentForAction(MSICOMPONENT*, INSTALLSTATE);
......
......@@ -43,47 +43,6 @@ const WCHAR cszSourceDir[] = {'S','o','u','r','c','e','D','i','r',0};
const WCHAR cszRootDrive[] = {'R','O','O','T','D','R','I','V','E',0};
const WCHAR cszbs[]={'\\',0};
DWORD build_version_dword(LPCWSTR version_string)
{
SHORT major,minor;
WORD build;
DWORD rc = 0x00000000;
LPCWSTR ptr1;
ptr1 = version_string;
if (!ptr1)
return rc;
else
major = atoiW(ptr1);
if(ptr1)
ptr1 = strchrW(ptr1,'.');
if (ptr1)
{
ptr1++;
minor = atoiW(ptr1);
}
else
minor = 0;
if (ptr1)
ptr1 = strchrW(ptr1,'.');
if (ptr1)
{
ptr1++;
build = atoiW(ptr1);
}
else
build = 0;
rc = MAKELONG(build,MAKEWORD(minor,major));
TRACE("%s -> 0x%lx\n",debugstr_w(version_string),rc);
return rc;
}
LPWSTR build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name )
{
LPWSTR SystemFolder, dest, FilePath;
......
......@@ -415,6 +415,9 @@ extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL cr
extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern DWORD msi_version_str_to_dword(LPCWSTR p);
extern LPWSTR msi_version_dword_to_str(DWORD version);
extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
......
......@@ -305,6 +305,38 @@ BOOL encode_base85_guid( GUID *guid, LPWSTR str )
return TRUE;
}
DWORD msi_version_str_to_dword(LPCWSTR p)
{
DWORD major, minor = 0, build = 0, version = 0;
if (!p)
return version;
major = atoiW(p);
p = strchrW(p, '.');
if (p)
{
minor = atoiW(p+1);
p = strchrW(p+1, '.');
if (p)
build = atoiW(p+1);
}
return MAKELONG(build, MAKEWORD(minor, major));
}
LPWSTR msi_version_dword_to_str(DWORD version)
{
const WCHAR fmt[] = { '%','u','.','%','u','.','%','u',0 };
LPWSTR str = msi_alloc(20);
sprintfW(str, fmt,
(version&0xff000000)>>24,
(version&0x00ff0000)>>16,
version&0x0000ffff);
return str;
}
LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
{
DWORD len = value ? (lstrlenW(value) + 1) * sizeof (WCHAR) : 0;
......
......@@ -151,7 +151,7 @@ static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
(LPBYTE)&check, &sz);
/* check min */
ver = MSI_RecordGetString(rec,2);
comp_ver = build_version_dword(ver);
comp_ver = msi_version_str_to_dword(ver);
r = check - comp_ver;
if (r < 0 || (r == 0 && !(attributes &
msidbUpgradeAttributesVersionMinInclusive)))
......@@ -163,7 +163,7 @@ static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
/* check max */
ver = MSI_RecordGetString(rec,3);
comp_ver = build_version_dword(ver);
comp_ver = msi_version_str_to_dword(ver);
r = check - comp_ver;
if (r > 0 || (r == 0 && !(attributes &
msidbUpgradeAttributesVersionMaxInclusive)))
......
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