[Libreoffice-commits] core.git: vcl/win

Fridrich Å trba fridrich.strba at bluewin.ch
Sun Jul 21 22:42:03 PDT 2013


 vcl/win/source/window/salframe.cxx |   70 +++++++++++--------------------------
 1 file changed, 22 insertions(+), 48 deletions(-)

New commits:
commit 50d330c3d238b7b6182787959b30a6d665eab078
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Sun Jul 21 19:18:58 2013 -0700

    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 at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index 45f8424..111bfea 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 );
     }
 }
 


More information about the Libreoffice-commits mailing list