Use advapi32.CommandLineFromMsiDescriptor to get msi component paths.
This commit is contained in:
parent
febe90b263
commit
85b3f37d31
|
@ -52,6 +52,7 @@
|
||||||
#include "shlguid.h"
|
#include "shlguid.h"
|
||||||
#include "shlwapi.h"
|
#include "shlwapi.h"
|
||||||
#include "msi.h"
|
#include "msi.h"
|
||||||
|
#include "appmgmt.h"
|
||||||
|
|
||||||
#include "initguid.h"
|
#include "initguid.h"
|
||||||
|
|
||||||
|
@ -2413,50 +2414,25 @@ ShellLink_QueryContextMenu( IContextMenu* iface, HMENU hmenu, UINT indexMenu,
|
||||||
return MAKE_HRESULT( SEVERITY_SUCCESS, 0, id );
|
return MAKE_HRESULT( SEVERITY_SUCCESS, 0, id );
|
||||||
}
|
}
|
||||||
|
|
||||||
static LPWSTR shelllink_get_msi_component_path( LPCWSTR component )
|
static LPWSTR
|
||||||
|
shelllink_get_msi_component_path( LPWSTR component )
|
||||||
{
|
{
|
||||||
UINT (WINAPI *pMsiDecomposeDescriptorW)(LPCWSTR,LPWSTR,LPWSTR,LPWSTR,DWORD*);
|
|
||||||
INSTALLSTATE (WINAPI *pMsiGetComponentPathW)(LPCWSTR,LPCWSTR,LPWSTR,DWORD*);
|
|
||||||
WCHAR szProd[MAX_FEATURE_CHARS+1], szFeat[MAX_FEATURE_CHARS+1],
|
|
||||||
szComp[MAX_FEATURE_CHARS+1], szCompPath[MAX_PATH];
|
|
||||||
INSTALLSTATE state;
|
|
||||||
LPWSTR path = NULL;
|
LPWSTR path = NULL;
|
||||||
HMODULE hmsi = NULL;
|
DWORD r, sz = 0;
|
||||||
DWORD sz = 0;
|
|
||||||
UINT ret;
|
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_w( component ) );
|
r = CommandLineFromMsiDescriptor( component, NULL, &sz );
|
||||||
|
if (r != ERROR_SUCCESS)
|
||||||
|
return path;
|
||||||
|
|
||||||
hmsi = LoadLibraryA("msi");
|
sz++;
|
||||||
if (!hmsi)
|
path = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) );
|
||||||
goto end;
|
r = CommandLineFromMsiDescriptor( component, path, &sz );
|
||||||
|
if (r != ERROR_SUCCESS)
|
||||||
pMsiDecomposeDescriptorW = (LPVOID) GetProcAddress(hmsi, "MsiDecomposeDescriptorW");
|
|
||||||
pMsiGetComponentPathW = (LPVOID) GetProcAddress(hmsi, "MsiGetComponentPathW");
|
|
||||||
if (!pMsiDecomposeDescriptorW || !pMsiGetComponentPathW)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
ret = pMsiDecomposeDescriptorW( component, szProd, szFeat, szComp, &sz );
|
|
||||||
if (ret != ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
ERR("failed to decompose descriptor %s\n", debugstr_w( component ) );
|
HeapFree( GetProcessHeap(), 0, path );
|
||||||
goto end;
|
path = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sz = MAX_PATH;
|
|
||||||
state = pMsiGetComponentPathW( szProd, szComp, szCompPath, &sz );
|
|
||||||
if (state != INSTALLSTATE_LOCAL)
|
|
||||||
{
|
|
||||||
ERR("MsiGetComponentPathW failed with error %d\n", ret );
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
path = strdupW( szCompPath );
|
|
||||||
|
|
||||||
end:
|
|
||||||
if (hmsi)
|
|
||||||
FreeLibrary( hmsi );
|
|
||||||
|
|
||||||
TRACE("returning %s\n", debugstr_w( path ) );
|
TRACE("returning %s\n", debugstr_w( path ) );
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
|
Loading…
Reference in New Issue