diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-06-01 12:03:57 +0200 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-06-01 12:03:57 +0200 |
| commit | db6974eda1dc1fada95af97ea53c369db58fda41 (patch) | |
| tree | e9ab96b1b8020e490f2e8d54757e1f1988d69f22 /alf/alfcompat.h | |
| parent | 79e8eb033fd2742b67966f5ff973f4ef64005531 (diff) | |
replace windows version checks with compat bits
this saves us from calling GetVersion() and massaging the result
in hot code paths
Diffstat (limited to 'alf/alfcompat.h')
| -rw-r--r-- | alf/alfcompat.h | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/alf/alfcompat.h b/alf/alfcompat.h index 8186492..eeb70da 100644 --- a/alf/alfcompat.h +++ b/alf/alfcompat.h @@ -15,25 +15,6 @@ extern IMAGE_DOS_HEADER __ImageBase; #endif #define ALF_HINSTANCE ((HINSTANCE)&__ImageBase) -static inline BOOL ALF_Compat_IsMinWindowsVersion(DWORD major, DWORD minor) -{ - DWORD v = GetVersion(); - DWORD vMajor = LOBYTE(LOWORD(v)); - DWORD vMinor = HIBYTE(LOWORD(v)); - - return vMajor > major || (vMajor == major && vMinor >= minor); -} - -static inline BOOL ALF_Compat_IsWin9x(void) -{ - return GetVersion() >= 0x80000000; -} - -static inline BOOL ALF_Compat_IsWinNT(void) -{ - return GetVersion() < 0x80000000; -} - typedef struct { UINT cbSize; int iBorderWidth; @@ -144,3 +125,49 @@ extern HRESULT (WINAPI *ALF_Compat_EndBufferedAnimation)(ALF_Compat_HANIMATIONBU extern BOOL (WINAPI *ALF_Compat_BufferedPaintRenderAnimation)(HWND,HDC); extern HRESULT (WINAPI *ALF_Compat_GetThemeTransitionDuration)(HTHEME,int,int,int,int,DWORD*); extern HRESULT (WINAPI *ALF_Compat_GetThemeColor)(HTHEME,int,int,int,COLORREF*); + +// compatibility bits + +#define ALF_COMPAT_ISNT 1 +#define ALF_COMPAT_IS40 2 +#define ALF_COMPAT_ISW2K 4 +#define ALF_COMPAT_ISXP 8 +#define ALF_COMPAT_ISVISTA 16 +#define ALF_COMPAT_ISCOMCTLV6 32 + +extern DWORD _alf_compatBits; + +static inline BOOL ALF_Compat_IsWin9x(void) +{ + return !(_alf_compatBits & ALF_COMPAT_ISNT); +} + +static inline BOOL ALF_Compat_IsNT(void) +{ + return !!(_alf_compatBits & ALF_COMPAT_ISNT); +} + +static inline BOOL ALF_Compat_Is40(void) // both NT 4.0 and Win95 +{ + return !!(_alf_compatBits & ALF_COMPAT_IS40); +} + +static inline BOOL ALF_Compat_Is2k(void) +{ + return !!(_alf_compatBits & ALF_COMPAT_ISW2K); +} + +static inline BOOL ALF_Compat_IsXP(void) +{ + return !!(_alf_compatBits & ALF_COMPAT_ISXP); +} + +static inline BOOL ALF_Compat_IsVista(void) +{ + return !!(_alf_compatBits & ALF_COMPAT_ISVISTA); +} + +static inline BOOL ALF_Compat_IsComCtlV6(void) +{ + return !!(_alf_compatBits & ALF_COMPAT_ISCOMCTLV6); +} |
