OSDN Git Service

ShellExtension VS2017(4) - Eliminate Warnings
authorGreyMerlin <GreyMerlin7@gmail.com>
Mon, 4 Sep 2017 06:34:54 +0000 (23:34 -0700)
committerGreyMerlin <GreyMerlin7@gmail.com>
Mon, 4 Sep 2017 17:31:29 +0000 (10:31 -0700)
 * Eliminate various compilation and linking warnings
 * Debug builds use Incremental linking
 * Debug builds don't use 'Safe Exception Handlers'
 * DLL exports no longer have assigned numbers
 * _vsntprintf() changed to _vsntprintf_s()
 * Make sure WINVER set to 0x501 (for XP compilation)
 * .rc file locally defines _USING_V110_SDK71_ to prevent duplicate
declaration warnings.  Note: this _USING_V110_SDK71_
definition is implicitly provided for all .cpp compilations by the
use of an Win-XP compatible Toolset, such as v141_xp)
 * All .h files now use #pragma once
 * Eliminate deprecation errors for GetVersionEx() by simulating Version
Helper code that works on all versions, Win2000 and beyond
(including WinXP)

ShellExtension/ShellExtension.rc
ShellExtension/ShellExtension.vs2015.vcxproj
ShellExtension/ShellExtension.vs2017.vcxproj
ShellExtension/ShellExtensionU.def
ShellExtension/ShellExtensionX64.def
ShellExtension/StdAfx.h
ShellExtension/WinMergeShell.cpp
ShellExtension/WinMergeShell.h
Src/Common/UnicodeString.cpp

index 46c1d7b..5bc8409 100644 (file)
@@ -7,6 +7,7 @@
 //\r
 // Generated from the TEXTINCLUDE 2 resource.\r
 //\r
+#define _USING_V110_SDK71_ 1\r
 #include "afxres.h"\r
 \r
 /////////////////////////////////////////////////////////////////////////////\r
@@ -32,6 +33,7 @@ END
 \r
 2 TEXTINCLUDE \r
 BEGIN\r
+       "#define _USING_V110_SDK71_ 1""\r\n"\r
     "#include ""afxres.h""\r\n"\r
     "\0"\r
 END\r
index 054d330..8fb6e05 100644 (file)
@@ -73,8 +73,8 @@
     <OutDir Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">.\..\Build\$(PlatformName)\$(ProjectName)$(Configuration)\</OutDir>
     <IntDir Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">.\..\BuildTmp\$(ProjectName)$(Configuration)\</IntDir>
     <IntDir Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">.\..\BuildTmp\$(PlatformName)\$(ProjectName)$(Configuration)\</IntDir>
-    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">false</LinkIncremental>
-    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">false</LinkIncremental>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">true</LinkIncremental>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">true</LinkIncremental>
     <OutDir Condition="'$(Configuration)|$(Platform)'=='Unicode Release MinDependency|Win32'">.\..\Build\$(ProjectName)$(Configuration)\</OutDir>
     <OutDir Condition="'$(Configuration)|$(Platform)'=='Unicode Release MinDependency|x64'">.\..\Build\$(PlatformName)\$(ProjectName)$(Configuration)\</OutDir>
     <IntDir Condition="'$(Configuration)|$(Platform)'=='Unicode Release MinDependency|Win32'">.\..\BuildTmp\$(ProjectName)$(Configuration)\</IntDir>
       <SubSystem>Windows</SubSystem>
       <ImportLibrary>$(IntDir)/$(TargetName).lib</ImportLibrary>
       <TargetMachine>MachineX86</TargetMachine>
+      <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
     </Link>
     <Midl>
       <TypeLibraryName>.\..\BuildTmp\ShellExtension__UnicodeDebug/ShellExtension.tlb</TypeLibraryName>
       <ProgramDatabaseFile>$(OutDir)/$(TargetName).pdb</ProgramDatabaseFile>
       <SubSystem>Windows</SubSystem>
       <ImportLibrary>$(IntDir)/$(TargetName).lib</ImportLibrary>
+      <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
     </Link>
     <Midl>
       <TypeLibraryName>.\..\BuildTmp\ShellExtension__UnicodeDebug/ShellExtension.tlb</TypeLibraryName>
index 589c971..a39872c 100644 (file)
@@ -73,8 +73,8 @@
     <OutDir Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">.\..\Build\$(PlatformName)\$(ProjectName)$(Configuration)\</OutDir>
     <IntDir Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">.\..\BuildTmp\$(ProjectName)$(Configuration)\</IntDir>
     <IntDir Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">.\..\BuildTmp\$(PlatformName)\$(ProjectName)$(Configuration)\</IntDir>
-    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">false</LinkIncremental>
-    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">false</LinkIncremental>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">true</LinkIncremental>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">true</LinkIncremental>
     <OutDir Condition="'$(Configuration)|$(Platform)'=='Unicode Release MinDependency|Win32'">.\..\Build\$(ProjectName)$(Configuration)\</OutDir>
     <OutDir Condition="'$(Configuration)|$(Platform)'=='Unicode Release MinDependency|x64'">.\..\Build\$(PlatformName)\$(ProjectName)$(Configuration)\</OutDir>
     <IntDir Condition="'$(Configuration)|$(Platform)'=='Unicode Release MinDependency|Win32'">.\..\BuildTmp\$(ProjectName)$(Configuration)\</IntDir>
       <SubSystem>Windows</SubSystem>
       <ImportLibrary>$(IntDir)/$(TargetName).lib</ImportLibrary>
       <TargetMachine>MachineX86</TargetMachine>
+      <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
     </Link>
     <Midl>
       <TypeLibraryName>.\..\BuildTmp\ShellExtension__UnicodeDebug/ShellExtension.tlb</TypeLibraryName>
       <ProgramDatabaseFile>$(OutDir)/$(TargetName).pdb</ProgramDatabaseFile>
       <SubSystem>Windows</SubSystem>
       <ImportLibrary>$(IntDir)/$(TargetName).lib</ImportLibrary>
+      <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
     </Link>
     <Midl>
       <TypeLibraryName>.\..\BuildTmp\ShellExtension__UnicodeDebug/ShellExtension.tlb</TypeLibraryName>
index e8f6685..cca7c88 100644 (file)
@@ -3,7 +3,7 @@
 LIBRARY      "ShellExtensionU.DLL"
 
 EXPORTS
-       DllCanUnloadNow     @1 PRIVATE
-       DllGetClassObject   @2 PRIVATE
-       DllRegisterServer   @3 PRIVATE
-       DllUnregisterServer     @4 PRIVATE
+       DllCanUnloadNow     PRIVATE
+       DllGetClassObject   PRIVATE
+       DllRegisterServer   PRIVATE
+       DllUnregisterServer     PRIVATE
index 4529bb9..54e7cab 100644 (file)
@@ -3,7 +3,7 @@
 LIBRARY      "ShellExtensionX64.DLL"\r
 \r
 EXPORTS\r
-       DllCanUnloadNow     @1 PRIVATE\r
-       DllGetClassObject   @2 PRIVATE\r
-       DllRegisterServer   @3 PRIVATE\r
-       DllUnregisterServer     @4 PRIVATE\r
+       DllCanUnloadNow     PRIVATE\r
+       DllGetClassObject   PRIVATE\r
+       DllRegisterServer   PRIVATE\r
+       DllUnregisterServer     PRIVATE\r
index 43bc342..60d0a1d 100644 (file)
@@ -2,17 +2,16 @@
 //      or project specific include files that are used frequently,
 //      but are changed infrequently
 
-#if !defined(AFX_STDAFX_H__DA167DA1_3B1D_4C04_A3B7_89B125096702__INCLUDED_)
-#define AFX_STDAFX_H__DA167DA1_3B1D_4C04_A3B7_89B125096702__INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #define STRICT
 #ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x0501
 #endif
+#ifndef WINVER
+#define WINVER 0x0501
+#endif 
 #define _ATL_APARTMENT_THREADED
 
 #include <atlbase.h>
@@ -21,7 +20,3 @@
 extern CComModule _Module;
 #include <atlcom.h>
 
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_STDAFX_H__DA167DA1_3B1D_4C04_A3B7_89B125096702__INCLUDED)
index f92b805..d33335f 100644 (file)
@@ -100,19 +100,57 @@ enum
 
 static String GetResourceString(UINT resourceID);
 
-bool IsWindowsVistaOrGreater()
+// GreyMerlin (03 Sept 2017) - The following Version Info checking code is a 
+// short extract from the Microsoft <versionhelpers.h> file.  Unfortunatly, 
+// that file is not available for WinXP-compatible Platform Toolsets (e.g. 
+// v141_xp for VS2017).  Fortunatly, all the actual API interfaces do exist 
+// in WinXP (actually, in all Windows products since Win2000).  Use of this 
+// <versionhelpers.h> code avoids the unpleasant deprecation of the GetVersionEx()
+// API begining with Win 8.1.  This Version Info checking code is also fully 
+// compatible with all non-XP-compatible Toolsets as well (e.g. v141).
+
+#ifndef _WIN32_WINNT_VISTA
+#define _WIN32_WINNT_VISTA     0x0600
+#endif
+#ifndef _WIN32_WINNT_WIN8
+#define _WIN32_WINNT_WIN8      0x0602
+#endif
+
+#ifndef VERSIONHELPERAPI
+#define VERSIONHELPERAPI inline bool
+
+VERSIONHELPERAPI
+IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
 {
-       OSVERSIONINFO ovi = { sizeof OSVERSIONINFO };
-       GetVersionEx(&ovi);
-       return (ovi.dwMajorVersion >= 6);
+    OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 };
+    DWORDLONG        const dwlConditionMask = VerSetConditionMask(
+        VerSetConditionMask(
+        VerSetConditionMask(
+            0, VER_MAJORVERSION, VER_GREATER_EQUAL),
+               VER_MINORVERSION, VER_GREATER_EQUAL),
+               VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
+
+    osvi.dwMajorVersion = wMajorVersion;
+    osvi.dwMinorVersion = wMinorVersion;
+    osvi.wServicePackMajor = wServicePackMajor;
+
+    return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
 }
 
-bool IsWindows8OrGreater()
+
+VERSIONHELPERAPI
+IsWindowsVistaOrGreater()
+{
+    return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
+}
+
+
+VERSIONHELPERAPI
+IsWindows8OrGreater()
 {
-       OSVERSIONINFO ovi = { sizeof OSVERSIONINFO };
-       GetVersionEx(&ovi);
-       return (ovi.dwMajorVersion * 1000 + ovi.dwMinorVersion >= 6002);
+    return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
 }
+#endif // VERSIONHELPERAPI
 
 class CWinMergeTempLocale
 {
index 35761b2..a3c2615 100644 (file)
@@ -24,8 +24,7 @@
 // ID line follows -- this is updated by SVN
 // $Id: WinMergeShell.h 6933 2009-07-26 14:07:03Z kimmov $
 
-#ifndef __WINMERGESHELL_H_
-#define __WINMERGESHELL_H_
+#pragma once
 
 #include <shlobj.h>
 #include <shlguid.h>
@@ -86,4 +85,3 @@ public:
        STDMETHOD(QueryContextMenu)(HMENU, UINT, UINT, UINT, UINT);
 };
 
-#endif //__WINMERGESHELL_H_
index ad16c9b..9805d01 100644 (file)
@@ -174,7 +174,7 @@ String format_arg_list(const TCHAR *fmt, va_list args)
        std::vector<TCHAR> buffer(length, 0);
        while (result == -1)
        {
-               result = _vsntprintf(&buffer[0], length, fmt, args);
+               result = _vsntprintf_s(&buffer[0], length, length, fmt, args);
                length *= 2;
                buffer.resize(length, 0);
        }