James Hawkins : msi: Set the WindowsInstaller value in RegisterProduct instead of PublishProduct .

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jul 3 08:01:34 CDT 2007


Module: wine
Branch: master
Commit: 0e44e090c591f485776c7e3898dec5a9e7296f85
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0e44e090c591f485776c7e3898dec5a9e7296f85

Author: James Hawkins <truiken at gmail.com>
Date:   Mon Jul  2 20:21:58 2007 -0700

msi: Set the WindowsInstaller value in RegisterProduct instead of PublishProduct.

---

 dlls/msi/action.c        |   28 +++++++++++++++++++---------
 dlls/msi/msipriv.h       |    1 +
 dlls/msi/registry.c      |   39 +++++++++++++++++++++++++++++++++++++++
 dlls/msi/tests/install.c |    5 +----
 4 files changed, 60 insertions(+), 13 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 6c857f0..37ad1ab 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -3279,10 +3279,6 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
         {'A','R','P','P','R','O','D','U','C','T','I','C','O','N',0};
     static const WCHAR szProductVersion[] =
         {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
-    static const WCHAR szInstallProperties[] =
-        {'I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0};
-    static const WCHAR szWindowsInstaller[] =
-        {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
     DWORD langid;
     LPWSTR buffer;
     DWORD size;
@@ -3315,12 +3311,10 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
     if (rc != ERROR_SUCCESS)
         goto end;
 
-    rc = RegCreateKeyW(hudkey, szInstallProperties, &props);
+    rc = MSIREG_OpenInstallPropertiesKey(package->ProductCode,&props,TRUE);
     if (rc != ERROR_SUCCESS)
         goto end;
 
-    msi_reg_set_val_dword( props, szWindowsInstaller, 1 );
-
     buffer = msi_dup_property( package, INSTALLPROPERTY_PRODUCTNAMEW );
     msi_reg_set_val_str( hukey, INSTALLPROPERTY_PRODUCTNAMEW, buffer );
     msi_free(buffer);
@@ -3806,6 +3800,7 @@ static UINT msi_write_uninstall_property_vals( MSIPACKAGE *package, HKEY hkey )
 static UINT ACTION_RegisterProduct(MSIPACKAGE *package)
 {
     HKEY hkey=0;
+    HKEY hudkey=0, props=0;
     LPWSTR buffer = NULL;
     UINT rc;
     DWORD size, langid;
@@ -3830,7 +3825,11 @@ static UINT ACTION_RegisterProduct(MSIPACKAGE *package)
     SYSTEMTIME systime;
     static const WCHAR date_fmt[] = {'%','i','%','i','%','i',0};
     LPWSTR upgrade_code;
-    WCHAR szDate[9]; 
+    WCHAR szDate[9];
+
+    /* FIXME: also need to publish if the product is in advertise mode */
+    if (!msi_check_publish(package))
+        return ERROR_SUCCESS;
 
     rc = MSIREG_OpenUninstallKey(package->ProductCode,&hkey,TRUE);
     if (rc != ERROR_SUCCESS)
@@ -3892,7 +3891,18 @@ static UINT ACTION_RegisterProduct(MSIPACKAGE *package)
     
     RegCloseKey(hkey);
 
-    /* FIXME: call ui_actiondata */
+    rc = MSIREG_OpenUserDataProductKey(package->ProductCode, &hudkey, TRUE);
+    if (rc != ERROR_SUCCESS)
+        return rc;
+
+    RegCloseKey(hudkey);
+
+    rc = MSIREG_OpenInstallPropertiesKey(package->ProductCode, &props, TRUE);
+    if (rc != ERROR_SUCCESS)
+        return rc;
+
+    msi_reg_set_val_dword( props, szWindowsInstaller, 1 );
+    RegCloseKey(props);
 
     return ERROR_SUCCESS;
 }
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 14a365e..a62f8d9 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -709,6 +709,7 @@ extern UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create
 extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
 extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
 extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY* key, BOOL create);
+extern UINT MSIREG_OpenInstallPropertiesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
 extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c
index 238cdd1..5787bc7 100644
--- a/dlls/msi/registry.c
+++ b/dlls/msi/registry.c
@@ -166,6 +166,16 @@ static const WCHAR szUserDataProd_fmt[] = {
 'U','s','e','r','D','a','t','a','\\',
 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s',0};
 
+static const WCHAR szInstallProperties_fmt[] = {
+'S','o','f','t','w','a','r','e','\\',
+'M','i','c','r','o','s','o','f','t','\\',
+'W','i','n','d','o','w','s','\\',
+'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
+'I','n','s','t','a','l','l','e','r','\\',
+'U','s','e','r','D','a','t','a','\\',
+'%','s','\\','P','r','o','d','u','c','t','s','\\','%','s','\\',
+'I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0};
+
 
 #define SQUISH_GUID_SIZE 33
 
@@ -611,6 +621,35 @@ UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY *key, BOOL create)
     return rc;
 }
 
+UINT MSIREG_OpenInstallPropertiesKey(LPCWSTR szProduct, HKEY *key, BOOL create)
+{
+    UINT rc;
+    WCHAR squished_pc[GUID_SIZE];
+    WCHAR keypath[0x200];
+    LPWSTR usersid;
+
+    TRACE("%s\n", debugstr_w(szProduct));
+    squash_guid(szProduct, squished_pc);
+    TRACE("squished (%s)\n", debugstr_w(squished_pc));
+
+    rc = get_user_sid(&usersid);
+    if (rc != ERROR_SUCCESS || !usersid)
+    {
+        ERR("Failed to retrieve user SID: %d\n", rc);
+        return rc;
+    }
+
+    sprintfW(keypath, szInstallProperties_fmt, usersid, squished_pc);
+
+    if (create)
+        rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
+    else
+        rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
+
+    msi_free(usersid);
+    return rc;
+}
+
 UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct)
 {
     UINT rc;
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index f6d59c8..4cf3ca4 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -1683,10 +1683,7 @@ static void test_publish(void)
     ok(pf_exists("msitest"), "File not installed\n");
 
     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
-    todo_wine
-    {
-        ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
-    }
+    ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
 
     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);




More information about the wine-cvs mailing list