From 66775b90e3df69bd9ddc05c36c33ed4432921969 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Tue, 8 Nov 2005 10:55:25 +0000 Subject: [PATCH] Extract the executable name for msi advertised shortcuts. --- programs/winemenubuilder/winemenubuilder.c | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index baa702ed627..b66df0ea232 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -52,6 +52,7 @@ #include #include #include +#include #include "wine/unicode.h" #include "wine/debug.h" @@ -726,6 +727,33 @@ static BOOL GetLinkLocation( LPCWSTR linkfile, DWORD *loc ) return FALSE; } +/* gets the target path directly or through MSI */ +static HRESULT get_path( IShellLinkW *sl, LPWSTR szPath, DWORD sz ) +{ + IShellLinkDataList *dl = NULL; + EXP_DARWIN_LINK *dar = NULL; + HRESULT hr; + + szPath[0] = 0; + hr = IShellLinkW_GetPath( sl, szPath, MAX_PATH, NULL, SLGP_RAWPATH ); + if (hr == S_OK && szPath[0]) + return hr; + + hr = IShellLinkW_QueryInterface( sl, &IID_IShellLinkDataList, (LPVOID*) &dl ); + if (FAILED(hr)) + return hr; + + hr = IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG, (LPVOID*) &dar ); + if (SUCCEEDED(hr)) + { + CommandLineFromMsiDescriptor( dar->szwDarwinID, szPath, &sz ); + LocalFree( dar ); + } + + IShellLinkDataList_Release( dl ); + return hr; +} + static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bAgain ) { char *link_name = NULL, *icon_name = NULL, *work_dir = NULL; @@ -760,8 +788,7 @@ static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bAgain ) IShellLinkW_GetDescription( sl, szDescription, INFOTIPSIZE ); WINE_TRACE("description: %s\n", wine_dbgstr_w(szDescription)); - szPath[0] = 0; - IShellLinkW_GetPath( sl, szPath, MAX_PATH, NULL, SLGP_RAWPATH ); + get_path( sl, szPath, MAX_PATH ); WINE_TRACE("path : %s\n", wine_dbgstr_w(szPath)); szArgs[0] = 0;