summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2013-07-21 19:18:58 -0700
committerFridrich Strba <fridrich@documentfoundation.org>2013-07-22 05:41:39 +0000
commit50d330c3d238b7b6182787959b30a6d665eab078 (patch)
treefc900592c5b372edc061094d575a0eaaf742099f
parentf9cde6e64ae23327a1c314195da638d81a5411ed (diff)
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/5016 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r--vcl/win/source/window/salframe.cxx70
1 files changed, 22 insertions, 48 deletions
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index 45f842468b06..111bfeafb9dc 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -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 );
}
}