Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup for Vista related code in the compile time. Cleanup copy-past from Windows SDK. It's probably fix for issues related to the Windows 7. Improve compilation time. #2068

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Src/ClassicExplorer/ClassicCopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,9 @@ static LRESULT CALLBACK WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
if (bDef)
{
delay=0;
if (GetWinVersion()>=WIN_VER_WIN7)
#if _WIN32_WINNT < _WIN32_WINNT_WIN7
if (GetWinVersion()>=_WIN32_WINNT_WIN7)
#endif
{
BOOL comp;
if (SUCCEEDED(DwmIsCompositionEnabled(&comp)) && comp)
Expand Down
2 changes: 1 addition & 1 deletion Src/ClassicExplorer/ClassicCopyExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ STDMETHODIMP CClassicCopyExt::InvokeCommand( LPCMINVOKECOMMANDINFO pCmdInfo )

HRESULT WINAPI CClassicCopyExt::UpdateRegistry( BOOL bRegister )
{
if (GetWinVersion()>=WIN_VER_WIN8)
if (GetWinVersion()>=_WIN32_WINNT_WIN8)
return S_OK;
return _AtlModule.UpdateRegistryFromResource(IDR_CLASSICCOPYEXT,bRegister);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// Open-Shell (c) 2017-2018, The Open-Shell Team
// Confidential information of Ivo Beltchev. Not for disclosure or distribution without prior written consent from the author

#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN
#define NOMINMAX
#include <windows.h>
#include <commctrl.h>
#include <shlwapi.h>
Expand Down
6 changes: 3 additions & 3 deletions Src/ClassicExplorer/ExplorerBHO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ LRESULT CALLBACK CExplorerBHO::SubclassTreeProc( HWND hWnd, UINT uMsg, WPARAM wP
indent=0;

int treeStyle=GetSettingInt(L"TreeStyle");
if (treeStyle==STYLE_CLASSIC && GetWinVersion()>=WIN_VER_WIN10)
if (treeStyle==STYLE_CLASSIC && GetWinVersion()>= _WIN32_WINNT_WIN10)
treeStyle=STYLE_VISTA;
DWORD style=GetWindowLong(hWnd,GWL_STYLE);
if (treeStyle!=STYLE_VISTA)
Expand Down Expand Up @@ -209,7 +209,7 @@ LRESULT CALLBACK CExplorerBHO::SubclassTreeProc( HWND hWnd, UINT uMsg, WPARAM wP
if (GetSettingBool(L"FullIndent"))
indent=0;

if (GetSettingInt(L"TreeStyle")==STYLE_CLASSIC && GetWinVersion()<WIN_VER_WIN10)
if (GetSettingInt(L"TreeStyle")==STYLE_CLASSIC && GetWinVersion()< _WIN32_WINNT_WIN10)
{
HIMAGELIST images=TreeView_GetImageList(hWnd,TVSIL_NORMAL);
int cx, cy;
Expand Down Expand Up @@ -1109,7 +1109,7 @@ HRESULT STDMETHODCALLTYPE CExplorerBHO::SetSite( IUnknown *pUnkSite )
SetProp(m_TopWindow,g_LoadedSettingsAtom,(HANDLE)1);
LoadSettings();
}
bool bWin8=(GetWinVersion()>=WIN_VER_WIN8);
bool bWin8=(GetWinVersion()>= _WIN32_WINNT_WIN8);

m_UpButtonIndex=bWin8?0:GetSettingInt(L"ShowUpButton");
bool bShowCaption=!bWin8 && GetSettingBool(L"ShowCaption");
Expand Down
13 changes: 10 additions & 3 deletions Src/ClassicExplorer/ExplorerBand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,9 @@ static bool GetPidlPath( PIDLIST_ABSOLUTE pidl, wchar_t *path )
path[0]=0;
if (SHGetPathFromIDList(pidl,path) && *path)
return true;
if (GetWinVersion()>=WIN_VER_WIN7)
#if _WIN32_WINNT < _WIN32_WINNT_WIN7
if (GetWinVersion()>= _WIN32_WINNT_WIN7)
#endif
{
// maybe it is a library - try the default save folder
CComPtr<IShellItem> pShellItem;
Expand Down Expand Up @@ -1747,7 +1749,7 @@ void CBandWindow::UpdateToolbar( void )

if (m_pBrowserBag)
{
if (GetWinVersion()>=WIN_VER_WIN8)
if (GetWinVersion()>= _WIN32_WINNT_WIN8)
{
VARIANT val={VT_EMPTY};
if (SUCCEEDED(m_pBrowserBag->Read(g_ComboPaneEnabled,&val,NULL)) && val.vt==VT_BOOL && !val.boolVal)
Expand Down Expand Up @@ -1983,7 +1985,12 @@ void CBandWindow::SetBrowsers( IShellBrowser *pBrowser, IWebBrowser2 *pWebBrowse

CExplorerBand::CExplorerBand( void )
{
m_bSubclassRebar=GetWinVersion()>=WIN_VER_WIN7;
m_bSubclassRebar =
#if _WIN32_WINNT < _WIN32_WINNT_WIN7
GetWinVersion() >= _WIN32_WINNT_WIN7;
#else
true;
#endif
m_bSubclassedRebar=false;
m_TopWindow=NULL;
}
Expand Down
12 changes: 6 additions & 6 deletions Src/ClassicExplorer/SettingsUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class CEditToolbarDlg: public CEditCustomItemDlg

LRESULT CEditToolbarDlg::OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
m_Style=GetWinVersion()>=WIN_VER_WIN8?SETTINGS_STYLE_WIN8:SETTINGS_STYLE_WIN7;
m_Style=GetWinVersion()>=_WIN32_WINNT_WIN8?SETTINGS_STYLE_WIN8:SETTINGS_STYLE_WIN7;
CWindow commands=GetDlgItem(IDC_COMBOCOMMAND);
CWindow links=GetDlgItem(IDC_COMBOLINK);
InitDialog(commands,g_StdCommands,m_Style,SETTINGS_STYLE_MASK,links,g_CommonLinks);
Expand Down Expand Up @@ -428,7 +428,7 @@ LRESULT CEditToolbarDlg::OnReset( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL
class CCustomToolbarDlg: public CCustomTreeDlg
{
public:
CCustomToolbarDlg( void ): CCustomTreeDlg(false,g_StdCommands,GetWinVersion()>=WIN_VER_WIN8?SETTINGS_STYLE_WIN8:SETTINGS_STYLE_WIN7,SETTINGS_STYLE_MASK) {}
CCustomToolbarDlg( void ): CCustomTreeDlg(false,g_StdCommands,GetWinVersion()>=_WIN32_WINNT_WIN8?SETTINGS_STYLE_WIN8:SETTINGS_STYLE_WIN7,SETTINGS_STYLE_MASK) {}

protected:
virtual void ParseTreeItemExtra( CTreeItem *pItem, CSettingsParser &parser );
Expand Down Expand Up @@ -604,7 +604,7 @@ void UpdateSettings( void )
UpdateSetting(L"UpIconSize",CComVariant((dpi>=120)?36:30),false);
FindSetting(L"UpHotkey2")->pLinkTo=FindSetting(L"UpHotkey");

if (GetWinVersion()>=WIN_VER_WIN8)
if (GetWinVersion()>=_WIN32_WINNT_WIN8)
{
// Windows 8
HideSettingGroup(L"StatusBar",true);
Expand All @@ -624,7 +624,7 @@ void UpdateSettings( void )
UpdateSetting(L"FixFolderScroll",CComVariant(0),false);
UpdateSetting(L"ToolbarItems",CComVariant(g_DefaultToolbar2),false);

if (GetWinVersion()>=WIN_VER_WIN10)
if (GetWinVersion()>=_WIN32_WINNT_WIN10)
{
FindSetting(L"TreeStyle")[1].flags|=CSetting::FLAG_HIDDEN;
}
Expand Down Expand Up @@ -657,14 +657,14 @@ static bool g_bCopyHook0; // initial state of the copy hook before the settings
void InitSettings( void )
{
InitSettings(g_Settings,COMPONENT_EXPLORER,NULL);
g_bCopyHook0=GetWinVersion()<WIN_VER_WIN8 && (GetSettingBool(L"ReplaceFileUI") || GetSettingBool(L"ReplaceFolderUI") || GetSettingBool(L"EnableMore"));
g_bCopyHook0=GetWinVersion()< _WIN32_WINNT_WIN8 && (GetSettingBool(L"ReplaceFileUI") || GetSettingBool(L"ReplaceFolderUI") || GetSettingBool(L"EnableMore"));
}

void ClosingSettings( HWND hWnd, int flags, int command )
{
if (command==IDOK)
{
bool bCopyHook=GetWinVersion()<WIN_VER_WIN8 && (GetSettingBool(L"ReplaceFileUI") || GetSettingBool(L"ReplaceFolderUI") || GetSettingBool(L"EnableMore"));
bool bCopyHook=GetWinVersion()< _WIN32_WINNT_WIN8 && (GetSettingBool(L"ReplaceFileUI") || GetSettingBool(L"ReplaceFolderUI") || GetSettingBool(L"EnableMore"));

if ((flags&CSetting::FLAG_COLD) || (bCopyHook && !g_bCopyHook0))
MessageBox(hWnd,LoadStringEx(IDS_NEW_SETTINGS2),LoadStringEx(IDS_APP_TITLE),MB_OK|MB_ICONWARNING);
Expand Down
2 changes: 1 addition & 1 deletion Src/ClassicExplorer/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ extern "C" BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpRe
const wchar_t *exe=PathFindFileName(path);
g_bExplorerExe=(_wcsicmp(exe,L"explorer.exe")==0 || _wcsicmp(exe,L"verclsid.exe")==0);
bool bReplaceUI=false;
if (GetWinVersion()<=WIN_VER_WIN7)
if (GetWinVersion()<=_WIN32_WINNT_WIN7)
{
settings[SETTING_REPLACE_FILE].LoadValue(regSettings,regSettingsUser,regPolicy,regPolicyUser);
settings[SETTING_REPLACE_FOLDER].LoadValue(regSettings,regSettingsUser,regPolicy,regPolicyUser);
Expand Down
3 changes: 3 additions & 0 deletions Src/ClassicExplorer/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_MODULES // compatibility with /permissive-
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#define VC_EXTRALEAN
#define NOMINMAX
#define _ATL_ALL_WARNINGS

#include "resource.h"
#include <atlbase.h>
Expand Down
15 changes: 6 additions & 9 deletions Src/ClassicExplorer/targetver.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Specifies that the minimum required platform is Windows 7.
#define WINVER 0x0602 // Change this to the appropriate value to target other versions of Windows.
#endif

#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows 7.
#define _WIN32_WINNT 0x0602 // Change this to the appropriate value to target other versions of Windows.
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows 7.
#define _WIN32_WINNT _WIN32_WINNT_WIN7 // Change this to the appropriate value to target other versions of Windows.
#endif

#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 11.0.
#define _WIN32_IE _WIN32_IE_IE110 // Change this to the appropriate value to target other versions of IE.
#endif

#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
#ifndef NTDDI_VERSION // Specifies that the minimum required platform is NTDDI for Windows 8.
#define NTDDI_VERSION NTDDI_WIN8 // Change this to the appropriate value to target other versions of NTDDI.
#endif
4 changes: 4 additions & 0 deletions Src/ClassicIE/ClassicIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

#define STRICT_TYPED_ITEMIDS
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN
#define NOMINMAX
#define _ATL_ALL_WARNINGS
#include <windows.h>
#include <commctrl.h>
#include <shlwapi.h>
Expand Down
8 changes: 5 additions & 3 deletions Src/ClassicIE/ClassicIEDLL/DrawCaption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ static LRESULT CALLBACK SubclassCaptionProc( HWND hWnd, UINT uMsg, WPARAM wParam
{
// exclude the caption buttons
rc.right-=g_SysButtonSize.cx+5;
if (GetWinVersion()==WIN_VER_VISTA) rc.bottom++;
#if _WIN32_WINNT > _WIN32_WINNT_VISTA
if (GetWinVersion()==_WIN32_WINNT_VISTA) rc.bottom++;
#endif
if (!bMaximized)
{
rc.left+=g_CustomCaption[0].leftPadding;
Expand All @@ -176,10 +178,10 @@ static LRESULT CALLBACK SubclassCaptionProc( HWND hWnd, UINT uMsg, WPARAM wParam
rc.left+=iconSize;
}
rc.left+=g_CustomCaption[1].iconPadding;
if (GetWinVersion()>=WIN_VER_WIN10)
if (GetWinVersion()>=_WIN32_WINNT_WIN10)
rc.bottom++;
}
if (GetWinVersion()<WIN_VER_WIN10)
if (GetWinVersion()<_WIN32_WINNT_WIN10)
rc.top=rc.bottom-g_SysButtonSize.cy;
HFONT font0=(HFONT)SelectObject(hdcPaint,font);
RECT rcText={0,0,0,0};
Expand Down
4 changes: 2 additions & 2 deletions Src/ClassicIE/ClassicIEDLL/SettingsUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void UpgradeSettings( bool bShared )

void UpdateSettings( void )
{
bool bWin8=(GetWinVersion()>=WIN_VER_WIN8);
bool bWin8=(GetWinVersion()>=_WIN32_WINNT_WIN8);

BOOL bComposition=0;
if (FAILED(DwmIsCompositionEnabled(&bComposition)))
Expand All @@ -75,7 +75,7 @@ void UpdateSettings( void )

UpdateSetting(L"Glow",CComVariant(bComposition?1:0),false);
UpdateSetting(L"MaxGlow",CComVariant(bComposition?1:0),false);
UpdateSetting(L"CenterCaption",CComVariant((bWin8 && GetWinVersion()<WIN_VER_WIN10)?1:0),false);
UpdateSetting(L"CenterCaption",CComVariant((bWin8 && GetWinVersion()<_WIN32_WINNT_WIN10)?1:0),false);

// create a dummy window to get a theme
HWND hwnd=CreateWindow(L"#32770",L"",WS_OVERLAPPEDWINDOW,0,0,0,0,NULL,NULL,NULL,0);
Expand Down
5 changes: 5 additions & 0 deletions Src/ClassicIE/ClassicIEDLL/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_MODULES // compatibility with /permissive-
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#define _ATL_ALL_WARNINGS


#include "resource.h"
#include <atlbase.h>
Expand Down
15 changes: 6 additions & 9 deletions Src/ClassicIE/ClassicIEDLL/targetver.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Specifies that the minimum required platform is Windows 7.
#define WINVER 0x0602 // Change this to the appropriate value to target other versions of Windows.
#endif

#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows 7.
#define _WIN32_WINNT 0x0602 // Change this to the appropriate value to target other versions of Windows.
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows 7.
#define _WIN32_WINNT _WIN32_WINNT_WIN7 // Change this to the appropriate value to target other versions of Windows.
#endif

#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 11.0.
#define _WIN32_IE _WIN32_IE_IE110 // Change this to the appropriate value to target other versions of IE.
#endif

#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
#ifndef NTDDI_VERSION // Specifies that the minimum required platform is NTDDI for Windows 8.
#define NTDDI_VERSION NTDDI_WIN8 // Change this to the appropriate value to target other versions of NTDDI.
#endif
20 changes: 10 additions & 10 deletions Src/Lib/ResourceHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Classic Shell (c) 2009-2017, Ivo Beltchev
// Open-Shell (c) 2017-2018, The Open-Shell Team
// Open-Shell (c) 2017-2024, The Open-Shell Team
// Confidential information of Ivo Beltchev. Not for disclosure or distribution without prior written consent from the author

#include "stdafx.h"
Expand Down Expand Up @@ -648,7 +648,7 @@ DWORD GetVersionEx( HINSTANCE hInstance, DWORD *pBuild )
}

// Returns the Windows version - 0x600, 0x601, ...
WORD GetWinVersion( void )
WORD GetWinVersion()
{
static WORD version;
if (!version)
Expand All @@ -660,29 +660,29 @@ WORD GetWinVersion( void )
return version;
}

static bool IsWin81Update1Helper( void )
static bool IsWin81Update1Helper()
{
DWORD build;
DWORD ver=GetVersionEx(GetModuleHandle(L"user32.dll"),&build);
return HIWORD(ver)==WIN_VER_WIN81 && build>17000;
return HIWORD(ver)==_WIN32_WINNT_WINBLUE && build>17000;
}

// Returns true if the version is Win81 Update1 or later
bool IsWin81Update1( void )
bool IsWin81Update1()
{
static bool bIsUpdate1=IsWin81Update1Helper();
return bIsUpdate1;
}

static bool IsWin10RS1Helper( void )
static bool IsWin10RS1Helper()
{
DWORD build;
DWORD ver=GetVersionEx(GetModuleHandle(L"user32.dll"),&build);
return ver>MAKELONG(14000,10<<8);
}

// Returns true if the version is Windows10 RS1 or later
bool IsWin10RS1( void )
bool IsWin10RS1()
{
static bool bIsRS1=IsWin10RS1Helper();
return bIsRS1;
Expand Down Expand Up @@ -720,14 +720,14 @@ static RTL_OSVERSIONINFOW GetOSVersion()
return ver;
}

static bool IsWin10RS4Helper( void )
static bool IsWin10RS4Helper()
{
auto version = GetOSVersion();
return version.dwMajorVersion > 8 && version.dwBuildNumber > 17131;
}

// Returns true if the version is Windows10 RS4 (Spring Creator Update) or later
bool IsWin10RS4( void )
bool IsWin10RS4()
{
static bool bIsRS4=IsWin10RS4Helper();
return bIsRS4;
Expand All @@ -740,7 +740,7 @@ static bool IsWin11Helper()
}

// Returns true if the version is Windows11 or later
bool IsWin11(void)
bool IsWin11()
{
static bool bIsWin11 = IsWin11Helper();
return bIsWin11;
Expand Down
16 changes: 5 additions & 11 deletions Src/Lib/ResourceHelper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Classic Shell (c) 2009-2017, Ivo Beltchev
// Open-Shell (c) 2017-2018, The Open-Shell Team
// Open-Shell (c) 2017-2024, The Open-Shell Team
// Confidential information of Ivo Beltchev. Not for disclosure or distribution without prior written consent from the author

#pragma once
Expand Down Expand Up @@ -49,23 +49,17 @@ HICON CreateDisabledIcon( HICON hIcon, int iconSize );
// Returns the version of a given module
DWORD GetVersionEx( HINSTANCE hInstance, DWORD *pBuild=NULL );

const int WIN_VER_VISTA=0x600;
const int WIN_VER_WIN7 =0x601;
const int WIN_VER_WIN8 =0x602;
const int WIN_VER_WIN81=0x603;
const int WIN_VER_WIN10=0xA00;

// Returns the Windows version - 0x600, 0x601, ...
WORD GetWinVersion( void );
WORD GetWinVersion();

// Returns true if the version is Win81 Update1
bool IsWin81Update1( void );
bool IsWin81Update1();

// Returns true if the version is Windows10 RS1 or later
bool IsWin10RS1( void );
bool IsWin10RS1();

// Returns true if the version is Windows10 RS4 (Spring Creator Update) or later
bool IsWin10RS4( void );
bool IsWin10RS4();

// Returns true if the version is Windows11 or later
bool IsWin11();
Expand Down
2 changes: 2 additions & 0 deletions Src/Lib/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <stdarg.h>

#if defined(_WIN32) || defined(_WIN64)
#define VC_EXTRALEAN
#define NOMINMAX
#include <windows.h>
#endif

Expand Down
Loading