summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesús Corrius <jcorrius@gmail.com>2013-04-27 20:11:25 +0200
committerTor Lillqvist <tml@iki.fi>2013-04-30 10:30:13 +0000
commit6c670f63a7859e24bdfa20759bd8b7c3b4a911ef (patch)
treec577f2d0d28429359e2ddc61ee16f5660bbeecb2
parent8d9337326745f3cd3ade623b3c01ad6e8e3e590d (diff)
fdo#35785: don't rely on the old apps fallback mechanism to fix this bug
Change-Id: Id0967358956868538f7563c51f7ed5e106771302 Reviewed-on: https://gerrit.libreoffice.org/3639 Reviewed-by: Tor Lillqvist <tml@iki.fi> Tested-by: Tor Lillqvist <tml@iki.fi>
-rw-r--r--desktop/win32/source/applauncher/launcher.cxx40
1 files changed, 39 insertions, 1 deletions
diff --git a/desktop/win32/source/applauncher/launcher.cxx b/desktop/win32/source/applauncher/launcher.cxx
index 0edcdbfa9cad..c6a40d34400b 100644
--- a/desktop/win32/source/applauncher/launcher.cxx
+++ b/desktop/win32/source/applauncher/launcher.cxx
@@ -34,6 +34,9 @@
#include <stdlib.h>
#include <malloc.h>
+#define PACKVERSION(major,minor) MAKELONG(minor,major)
+#define APPUSERMODELID L"TheDocumentFoundation.LibreOffice"
+
#ifdef __MINGW32__
extern "C" int APIENTRY WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
@@ -41,7 +44,42 @@ extern "C" int APIENTRY WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
#endif
{
- // Retrieve startup info
+ // Set an explicit Application User Model ID for the process
+
+ WCHAR szShell32[MAX_PATH];
+ GetSystemDirectoryW(szShell32, MAX_PATH);
+ wcscat(szShell32, L"\\Shell32.dll");
+
+ HINSTANCE hinstDll = LoadLibraryW(szShell32);
+
+ if(hinstDll)
+ {
+ DLLVERSIONINFO dvi;
+ ZeroMemory(&dvi, sizeof(dvi));
+ dvi.cbSize = sizeof(dvi);
+
+ DLLGETVERSIONPROC pDllGetVersion;
+ pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion");
+ HRESULT hr = (*pDllGetVersion)(&dvi);
+
+ if(SUCCEEDED(hr))
+ {
+ DWORD dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion);
+ if(dwVersion >= PACKVERSION(6,1)) // Shell32 version in Windows 7
+ {
+ typedef HRESULT (WINAPI *SETCURRENTPROCESSEXPLICITAPPUSERMODELID)(PCWSTR);
+ SETCURRENTPROCESSEXPLICITAPPUSERMODELID pSetCurrentProcessExplicitAppUserModelID;
+ pSetCurrentProcessExplicitAppUserModelID =
+ (SETCURRENTPROCESSEXPLICITAPPUSERMODELID)GetProcAddress(hinstDll, "SetCurrentProcessExplicitAppUserModelID");
+
+ if(pSetCurrentProcessExplicitAppUserModelID)
+ (*pSetCurrentProcessExplicitAppUserModelID) (APPUSERMODELID);
+ }
+ }
+ }
+ FreeLibrary(hinstDll);
+
+ // Retreive startup info
STARTUPINFO aStartupInfo;