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

@@ -589,7 +589,6 @@ $(TAB)$(VC_COMPILER) /EP /nologo "$(DOLLAR)(InputPath)" > "$(SETUPHDIR)\wx\msw\r
<!-- this one is only used if wxUSE_URL_NATIVE==1 but we don't
know if it is here so just add it unconditionally -->
<sys-lib>wininet</sys-lib>
<sys-lib>shlwapi</sys-lib>
</if>
<if cond="FORMAT=='borland'">
<sys-lib>oleacc</sys-lib>

View File

@@ -299,7 +299,6 @@
<sys-lib>rpcrt4</sys-lib>
<sys-lib>advapi32</sys-lib>
<sys-lib>wsock32</sys-lib>
<sys-lib>shlwapi</sys-lib>
</if>
<!-- Libs common to both borland and MSVC -->

View File

@@ -20,7 +20,8 @@ namespace {
class WXDLLIMPEXP_FWD_CORE ITaskbarList3;
}
class WXDLLIMPEXP_CORE wxTaskBarButtonImpl : public wxTaskBarButton {
class WXDLLIMPEXP_CORE wxTaskBarButtonImpl : public wxTaskBarButton
{
public:
virtual ~wxTaskBarButtonImpl();

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,8 +340,31 @@ 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 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);