Kaydet (Commit) 50d330c3 authored tarafından Fridrich Štrba's avatar Fridrich Štrba Kaydeden (comit) Fridrich Strba

Shell32.dll is already loaded

Since the vcllo.dll links already the shell32.dll because of its symbol
SHAddToRecentDocs, no need to increase reference of that library. Just
get the module handle.

Moreover, a mere presence of the symbol SHGetPropertyStoreForWindow in
shell32.dll indicates that we are running at least on Windows 7 or Windows
Server 2008 R2. There is thus no need to check for the library version.

Change-Id: I9ddfb8407fd805faf588779ac5fa8c10a0ae8898
Reviewed-on: https://gerrit.libreoffice.org/5016Reviewed-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
Tested-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
üst f9cde6e6
......@@ -1910,62 +1910,36 @@ void WinSalFrame::SetApplicationID( const OUString &rApplicationID )
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd378430(v=vs.85).aspx
// A window's properties must be removed before the window is closed.
WCHAR szShell32[MAX_PATH];
GetSystemDirectoryW( szShell32, MAX_PATH );
wcscat( szShell32, L"\\Shell32.dll" );
typedef HRESULT ( WINAPI *SHGETPROPERTYSTOREFORWINDOW )( HWND, REFIID, void ** );
SHGETPROPERTYSTOREFORWINDOW pSHGetPropertyStoreForWindow;
pSHGetPropertyStoreForWindow = ( SHGETPROPERTYSTOREFORWINDOW )GetProcAddress(
GetModuleHandleW (L"shell32.dll"), "SHGetPropertyStoreForWindow" );
HINSTANCE hinstDll = LoadLibraryW( szShell32 );
if( hinstDll )
// A mere presence of the symbol means we are at least on Windows 7 or Windows Server 2008 R2
if( pSHGetPropertyStoreForWindow )
{
DLLVERSIONINFO dvi;
ZeroMemory(&dvi, sizeof(dvi));
dvi.cbSize = sizeof(dvi);
DLLGETVERSIONPROC pDllGetVersion;
pDllGetVersion = ( DLLGETVERSIONPROC )GetProcAddress( hinstDll, "DllGetVersion" );
HRESULT hr = (*pDllGetVersion)(&dvi);
if( SUCCEEDED(hr) )
IPropertyStore *pps;
HRESULT hr = pSHGetPropertyStoreForWindow ( mhWnd, IID_PPV_ARGS(&pps) );
if ( SUCCEEDED(hr) )
{
#define PACKVERSION(major,minor) MAKELONG(minor,major)
DWORD dwVersion = PACKVERSION( dvi.dwMajorVersion, dvi.dwMinorVersion );
// shell32 in Windows 7 is version 6.1.
if( dwVersion >= PACKVERSION(6,1) )
PROPVARIANT pv;
if ( !rApplicationID.isEmpty() )
{
typedef HRESULT ( WINAPI *SHGETPROPERTYSTOREFORWINDOW )( HWND, REFIID, void ** );
SHGETPROPERTYSTOREFORWINDOW pSHGetPropertyStoreForWindow;
pSHGetPropertyStoreForWindow =
( SHGETPROPERTYSTOREFORWINDOW ) GetProcAddress( hinstDll, "SHGetPropertyStoreForWindow" );
hr = InitPropVariantFromString( rApplicationID.getStr(), &pv );
mbPropertiesStored = TRUE;
}
else
// if rApplicationID we remove the property from the window, if present
PropVariantInit( &pv );
if( pSHGetPropertyStoreForWindow )
{
IPropertyStore *pps;
HRESULT hr = ( *pSHGetPropertyStoreForWindow ) ( mhWnd, IID_PPV_ARGS(&pps) );
if ( SUCCEEDED(hr) )
{
PROPVARIANT pv;
if ( !rApplicationID.isEmpty() )
{
hr = InitPropVariantFromString( rApplicationID.getStr(), &pv );
mbPropertiesStored = TRUE;
}
else
// if rApplicationID we remove the property from the window, if present
PropVariantInit( &pv );
if ( SUCCEEDED(hr) )
{
hr = pps->SetValue( PKEY_AppUserModel_ID, pv );
PropVariantClear( &pv );
}
pps->Release();
}
}
if ( SUCCEEDED(hr) )
{
hr = pps->SetValue( PKEY_AppUserModel_ID, pv );
PropVariantClear( &pv );
}
pps->Release();
}
}
FreeLibrary( hinstDll );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment