Don't link shlwapi directly.

For MSVC use #pragma comment to link shlwapi, and for MinGW use dynamic
loading of this library.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77635 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2014-09-10 14:57:06 +00:00
parent eb4cdf4a3d
commit cf5b3021c6
4 changed files with 35 additions and 5 deletions

View File

@@ -21,12 +21,20 @@
#if wxUSE_TASKBARBUTTON
#ifdef _MSC_VER
#pragma comment( lib, "shlwapi" )
#endif
#include "wx/msw/private.h"
#include "wx/msw/taskbarbutton.h"
#include <shlwapi.h>
#include <initguid.h>
#if wxUSE_DYNLIB_CLASS
#include "wx/dynlib.h"
#endif // wxUSE_DYNLIB_CLASS
// ----------------------------------------------------------------------------
// Redefine the interfaces: ITaskbarList3, IObjectCollection,
// ICustomDestinationList, IShellLink, IShellItem, IApplicationDocumentLists
@@ -332,9 +340,32 @@ inline HRESULT InitPropVariantFromBoolean(BOOL fVal, PROPVARIANT *ppropvar)
inline HRESULT InitPropVariantFromString(PCWSTR psz, PROPVARIANT *ppropvar)
{
HRESULT hr = E_FAIL;
ppropvar->vt = VT_LPWSTR;
HRESULT hr = SHStrDupW(psz, &ppropvar->pwszVal);
if (FAILED(hr))
#if wxUSE_DYNLIB_CLASS
typedef HRESULT (WINAPI *SHStrDupW_t)(LPCTSTR, LPTSTR*);
static SHStrDupW_t s_pfnSHStrDupW = NULL;
if ( !s_pfnSHStrDupW )
{
wxDynamicLibrary dll(wxT("shlwapi.dll"));
if ( dll.IsLoaded() )
{
s_pfnSHStrDupW = (SHStrDupW_t)dll.GetSymbol(wxT("SHStrDupW"));
}
}
if ( s_pfnSHStrDupW )
{
hr = s_pfnSHStrDupW(psz, &ppropvar->pwszVal);
}
#elif defined (_MSC_VER)
hr = SHStrDupW(psz, &ppropvar->pwszVal);
#else
wxUnusedVar(psz);
#endif
if ( FAILED(hr) )
{
PropVariantInit(ppropvar);
}