From 57a672e41da2cba46722e337a80f9c080b39305d Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Fri, 27 Sep 2013 14:02:34 +0000
Subject: ShellExt shall not call mir_core.dll

git-svn-id: http://svn.miranda-ng.org/main/trunk@6250 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 plugins/ShellExt/src/Version.h  |  2 +-
 plugins/ShellExt/src/main.cpp   |  3 +++
 plugins/ShellExt/src/shlcom.cpp |  4 ++--
 plugins/ShellExt/src/shlext.cpp | 14 +++++++-------
 plugins/ShellExt/src/stdafx.h   |  1 +
 5 files changed, 14 insertions(+), 10 deletions(-)

(limited to 'plugins/ShellExt/src')

diff --git a/plugins/ShellExt/src/Version.h b/plugins/ShellExt/src/Version.h
index a0257b4297..5adf2fa76e 100644
--- a/plugins/ShellExt/src/Version.h
+++ b/plugins/ShellExt/src/Version.h
@@ -1,7 +1,7 @@
 #define __MAJOR_VERSION      2
 #define __MINOR_VERSION      2
 #define __RELEASE_NUM        0
-#define __BUILD_NUM          2
+#define __BUILD_NUM          3
 
 #define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
 #define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
diff --git a/plugins/ShellExt/src/main.cpp b/plugins/ShellExt/src/main.cpp
index e6b87adf42..24e1cdc736 100644
--- a/plugins/ShellExt/src/main.cpp
+++ b/plugins/ShellExt/src/main.cpp
@@ -3,6 +3,7 @@
 
 HINSTANCE hInst;
 int hLangpack;
+bool bIsVistaPlus;
 
 TCHAR tszLogPath[MAX_PATH];
 
@@ -23,6 +24,8 @@ PLUGININFOEX pluginInfoEx = {
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
 	if (fdwReason == DLL_PROCESS_ATTACH) {
+		bIsVistaPlus = GetProcAddress( GetModuleHandleA("kernel32.dll"), "GetProductInfo") != NULL;
+
 		GetTempPath(SIZEOF(tszLogPath), tszLogPath);
 		_tcscat_s(tszLogPath, SIZEOF(tszLogPath), _T("shlext.log"));
 
diff --git a/plugins/ShellExt/src/shlcom.cpp b/plugins/ShellExt/src/shlcom.cpp
index 3ecc0363ec..5457f5e307 100644
--- a/plugins/ShellExt/src/shlcom.cpp
+++ b/plugins/ShellExt/src/shlcom.cpp
@@ -561,7 +561,7 @@ HRESULT RemoveCOMRegistryEntries()
 
 void CheckUnregisterServer()
 {
-	if ( IsWinVerVistaPlus()) {
+	if (bIsVistaPlus) {
 		// launches regsvr to remove the dll under admin.
 		TCHAR szFileName[MAX_PATH], szBuf[MAX_PATH * 2];
 		GetModuleFileName(hInst, szFileName, SIZEOF(szFileName));
@@ -589,7 +589,7 @@ void CheckRegisterServer()
 	HKEY hRegKey;
 	if ( !RegOpenKeyExA(HKEY_CLASSES_ROOT, "miranda.shlext", 0, KEY_READ, &hRegKey))
 		RegCloseKey(hRegKey);
-	else if ( IsWinVerVistaPlus()) {
+	else if (bIsVistaPlus) {
 		MessageBoxA(0,
 			"Shell context menus requires your permission to register with Windows Explorer (one time only).",
 			"Miranda NG - Shell context menus (shellext.dll)", MB_OK | MB_ICONINFORMATION);
diff --git a/plugins/ShellExt/src/shlext.cpp b/plugins/ShellExt/src/shlext.cpp
index 29434221d9..64f46e1855 100644
--- a/plugins/ShellExt/src/shlext.cpp
+++ b/plugins/ShellExt/src/shlext.cpp
@@ -212,7 +212,7 @@ void DecideMenuItemInfo(TSlotIPC *pct, TGroupNode *pg, MENUITEMINFOA &mii, TEnum
 			mii.dwTypeData = pg->szGroup;
 
 		// For Vista + let the system draw the theme && icons, pct = contact associated data
-		if ( IsWinVerVistaPlus() && pct != NULL && psd != NULL) {
+		if (bIsVistaPlus && pct != NULL && psd != NULL) {
 			mii.fMask = MIIM_BITMAP | MIIM_FTYPE | MIIM_ID | MIIM_DATA | MIIM_STRING;
 			// BuildSkinIcons() built an array of bitmaps which we can use here
 			mii.hbmpItem = psd->hStatusBitmap;
@@ -237,7 +237,7 @@ int __stdcall ClearMRUIPC(
 
 void RemoveCheckmarkSpace(HMENU HMENU)
 {
-	if ( !IsWinVerVistaPlus())
+	if (!bIsVistaPlus)
 		return;
 
 	MENUINFO mi;
@@ -473,7 +473,7 @@ static void BuildMenus(TEnumData *lParam)
 	// allocate display info/memory for "Miranda" string
 
 	mii.cbSize = sizeof(MENUITEMINFO);
-	if ( IsWinVerVistaPlus())
+	if (bIsVistaPlus)
 		mii.fMask = MIIM_ID | MIIM_DATA | MIIM_FTYPE | MIIM_SUBMENU | MIIM_STRING | MIIM_BITMAP;
 	else
 		mii.fMask = MIIM_ID | MIIM_DATA | MIIM_TYPE | MIIM_SUBMENU;
@@ -532,7 +532,7 @@ static void BuildMenus(TEnumData *lParam)
 
 static void BuildSkinIcons(TEnumData *lParam)
 {
-	IWICImagingFactory *factory = ( IsWinVerVistaPlus()) ? ARGB_GetWorker() : NULL;
+	IWICImagingFactory *factory = (bIsVistaPlus) ? ARGB_GetWorker() : NULL;
 
 	TSlotIPC *pct = lParam->ipch->NewIconsBegin;
 	TShellExt *Self = lParam->Self;
@@ -550,7 +550,7 @@ static void BuildSkinIcons(TEnumData *lParam)
 		// with the shell object.
 
 		for (int j = 0; j < 10; j++) {
-			if ( IsWinVerVistaPlus()) {
+			if (bIsVistaPlus) {
 				d->hBitmaps[j] = ARGB_BitmapFromIcon(factory, Self->hMemDC, p->hIcons[j]);
 				d->hIcons[j] = NULL;				
 			}
@@ -654,7 +654,7 @@ HRESULT TShellExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT _idCmdFirs
 		}
 
 		// if we're using Vista (or later),  the ownerdraw code will be disabled, because the system draws the icons.
-		if ( IsWinVerVistaPlus())
+		if (bIsVistaPlus)
 			bMF_OWNERDRAW = false;
 
 		HANDLE hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, IPC_PACKET_SIZE, IPC_PACKET_NAME);
@@ -901,7 +901,7 @@ HRESULT TShellExt::HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESU
 		MEASUREITEMSTRUCT *msi = (MEASUREITEMSTRUCT*)lParam;
 		TMenuDrawInfo *psd = (TMenuDrawInfo*)msi->itemData;
 		NONCLIENTMETRICS ncm;
-		ncm.cbSize = (IsWinVerVistaPlus()) ? sizeof(ncm) : offsetof(NONCLIENTMETRICS, iPaddedBorderWidth);
+		ncm.cbSize = (bIsVistaPlus) ? sizeof(ncm) : offsetof(NONCLIENTMETRICS, iPaddedBorderWidth);
 		SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
 		// create the font used in menus, this font should be cached somewhere really
 		HFONT hFont = CreateFontIndirect(&ncm.lfMenuFont);
diff --git a/plugins/ShellExt/src/stdafx.h b/plugins/ShellExt/src/stdafx.h
index bf47755b11..83fc655a65 100644
--- a/plugins/ShellExt/src/stdafx.h
+++ b/plugins/ShellExt/src/stdafx.h
@@ -46,6 +46,7 @@ HRESULT RemoveCOMRegistryEntries();
 
 extern  HINSTANCE hInst;
 extern  HANDLE hLogger;
+extern  bool bIsVistaPlus;
 extern  int DllFactoryCount, DllObjectCount;
 
 int OnOptionsInit(WPARAM wParam, LPARAM lParam);
-- 
cgit v1.2.3