Mike McCormack : msi: Add support for INSTALLSTATE_ADVERTISED to MsiQueryFeatureState.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 17 08:14:45 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: a5a91d17a474a4f44356c04a90f1db51cafa5a04
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=a5a91d17a474a4f44356c04a90f1db51cafa5a04

Author: Mike McCormack <mike at codeweavers.com>
Date:   Sat Jul 15 11:05:20 2006 +0900

msi: Add support for INSTALLSTATE_ADVERTISED to MsiQueryFeatureState.

---

 dlls/msi/msi.c |   64 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index b8aeba2..a3f7a32 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -1117,10 +1117,12 @@ end:
  */
 INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
 {
-    WCHAR squishProduct[GUID_SIZE], buffer[MAX_FEATURE_CHARS+2];
+    WCHAR squishProduct[GUID_SIZE], comp[39];
+    GUID guid;
+    LPWSTR components, p, parent_feature;
     UINT rc;
-    DWORD sz, type;
     HKEY hkey;
+    INSTALLSTATE r;
 
     TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
 
@@ -1130,30 +1132,62 @@ INSTALLSTATE WINAPI MsiQueryFeatureState
     if (!squash_guid( szProduct, squishProduct ))
         return INSTALLSTATE_INVALIDARG;
 
+    /* check that it's installed at all */
     rc = MSIREG_OpenUserFeaturesKey(szProduct, &hkey, FALSE);
     if (rc != ERROR_SUCCESS)
         return INSTALLSTATE_UNKNOWN;
 
-    buffer[0] = 0;
-    sz = sizeof buffer;
-    type = 0;
-    rc = RegQueryValueExW(hkey, szFeature, NULL, &type, (LPBYTE) buffer, &sz);
+    parent_feature = msi_reg_get_val_str( hkey, szFeature );
     RegCloseKey(hkey);
 
-    TRACE("rc = %d buffer = %s\n", rc, debugstr_w(buffer));
+    if (!parent_feature)
+        return INSTALLSTATE_UNKNOWN;
+
+    r = (parent_feature[0] == 6) ? INSTALLSTATE_ABSENT : INSTALLSTATE_LOCAL;
+    msi_free(parent_feature);
+    if (r == INSTALLSTATE_ABSENT)
+        return r;
 
-    if (rc != ERROR_SUCCESS || sz == 0 || type != REG_SZ)
+    /* now check if it's complete or advertised */
+    rc = MSIREG_OpenFeaturesKey(szProduct, &hkey, FALSE);
+    if (rc != ERROR_SUCCESS)
         return INSTALLSTATE_UNKNOWN;
 
-    if (buffer[0] == 6)
-        return INSTALLSTATE_ABSENT;
+    components = msi_reg_get_val_str( hkey, szFeature );
+    RegCloseKey(hkey);
 
-    /* FIXME:
-     * Return INSTALLSTATE_ADVERTISED when
-     * the components exist in the registry, but not on the disk.
-     */
+    TRACE("rc = %d buffer = %s\n", rc, debugstr_w(components));
 
-    return INSTALLSTATE_LOCAL;
+    if (!components)
+    {
+        ERR("components missing %s %s\n",
+            debugstr_w(szProduct), debugstr_w(szFeature));
+        return INSTALLSTATE_UNKNOWN;
+    }
+
+    r = INSTALLSTATE_LOCAL;
+    for( p = components; (*p != 2) && (lstrlenW(p) > GUID_SIZE); p += GUID_SIZE)
+    {
+        if (!decode_base85_guid( p, &guid ))
+        {
+            ERR("%s\n", debugstr_w(p));
+            break;
+        }
+        StringFromGUID2(&guid, comp, 39);
+        r = MsiGetComponentPathW(szProduct, comp, NULL, 0);
+        if (r != INSTALLSTATE_LOCAL && r != INSTALLSTATE_SOURCE)
+        {
+            TRACE("component %s state %d\n", debugstr_guid(&guid), r);
+            r = INSTALLSTATE_ADVERTISED;
+        }
+    }
+
+    if (r == INSTALLSTATE_LOCAL && *p != 2)
+        ERR("%s -> %s\n", debugstr_w(szFeature), debugstr_w(components));
+
+    msi_free(components);
+
+    return r;
 }
 
 /******************************************************************




More information about the wine-cvs mailing list