msi: improved implementation of MsiGetComponentPath[A/W]

Aric Stewart aric at codeweavers.com
Fri Jan 14 01:24:59 CST 2005


Actually start on an implemention for MsiGetComponentPathW that should 
handle all keypaths that are files.

-------------- next part --------------
Index: dlls/msi/msi.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/msi.c,v
retrieving revision 1.46
diff -u -u -r1.46 msi.c
--- dlls/msi/msi.c	11 Jan 2005 15:46:43 -0000	1.46
+++ dlls/msi/msi.c	14 Jan 2005 07:24:38 -0000
@@ -1259,7 +1259,7 @@
                                          LPSTR lpPathBuf, DWORD* pcchBuf)
 {
     INSTALLSTATE rc;
-    UINT len;
+    UINT len,incomming_len;
     LPWSTR szwProduct= NULL;
     LPWSTR szwComponent= NULL;
     LPWSTR lpwPathBuf= NULL;
@@ -1290,14 +1290,15 @@
     else
         lpwPathBuf = NULL;
 
+    incomming_len = *pcchBuf;
     rc = MsiGetComponentPathW(szwProduct, szwComponent, lpwPathBuf, pcchBuf);
 
     HeapFree( GetProcessHeap(), 0, szwProduct);
     HeapFree( GetProcessHeap(), 0, szwComponent);
     if (lpwPathBuf)
     {
-        WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, *pcchBuf,
-                            lpPathBuf, GUID_SIZE, NULL, NULL);
+        WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, incomming_len,
+                            lpPathBuf, incomming_len, NULL, NULL);
         HeapFree( GetProcessHeap(), 0, lpwPathBuf);
     }
 
@@ -1307,10 +1308,58 @@
 INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
                                          LPWSTR lpPathBuf, DWORD* pcchBuf)
 {
-    FIXME("STUB: (%s %s %p %p)\n", debugstr_w(szProduct),
+    WCHAR squished_pc[0x100];
+    WCHAR squished_cc[0x100];
+    UINT rc;
+    INSTALLSTATE rrc = INSTALLSTATE_ABSENT;
+    HKEY hkey=0,hkey2=0,hkey3=0;
+    static const WCHAR szInstaller[] = {
+         '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',0 };
+    static const WCHAR szComponents[] = {
+         'C','o','m','p','o','n','e','n','t','s',0 };
+
+    TRACE("(%s %s %p %p)\n", debugstr_w(szProduct),
            debugstr_w(szComponent), lpPathBuf, pcchBuf);
 
-    return INSTALLSTATE_UNKNOWN;
+    squash_guid(szProduct,squished_pc);
+    squash_guid(szComponent,squished_cc);
+
+    rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,szInstaller,&hkey);
+    if (rc != ERROR_SUCCESS)
+        goto end;
+
+    rc = RegOpenKeyW(hkey,szComponents,&hkey2);
+    if (rc != ERROR_SUCCESS)
+        goto end;
+
+    rc = RegOpenKeyW(hkey2,squished_cc,&hkey3);
+    if (rc != ERROR_SUCCESS)
+        goto end;
+
+    *pcchBuf *= sizeof(WCHAR);
+    rc = RegQueryValueExW(hkey3,squished_pc,NULL,NULL,(LPVOID)lpPathBuf,
+                          pcchBuf);
+    *pcchBuf /= sizeof(WCHAR);
+
+    if (rc!= ERROR_SUCCESS)
+        goto end;
+
+    TRACE("found path of (%s:%s)(%s)\n", debugstr_w(squished_cc),
+           debugstr_w(squished_pc), debugstr_w(lpPathBuf));
+
+    FIXME("Only working for installed files, not registry keys\n");
+    if (GetFileAttributesW(lpPathBuf) != INVALID_FILE_ATTRIBUTES)
+        rrc = INSTALLSTATE_LOCAL;
+
+end:
+    RegCloseKey(hkey3);
+    RegCloseKey(hkey2);
+    RegCloseKey(hkey);
+    return rrc;
 }
 
 INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)


More information about the wine-patches mailing list