Skip to content

Commit

Permalink
Mantis 5983: CheckWin32Version is unsafe under D6
Browse files Browse the repository at this point in the history
  • Loading branch information
obones committed Dec 13, 2013
1 parent 8a580e5 commit 825400a
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 46 deletions.
11 changes: 7 additions & 4 deletions jvcl/devtools/JvExVCL/src/JvExMask.pas
Expand Up @@ -106,6 +106,9 @@ TJvExMaskEdit = class(TMaskEdit, IJvExControl)

implementation

uses
JclSysInfo;

{$IFNDEF COMPILER12_UP}
const
ECM_FIRST = $1500;
Expand Down Expand Up @@ -160,7 +163,7 @@ procedure TJvExCustomMaskEdit.CreateWnd;
function TJvExCustomMaskEdit.UserTextHint: Boolean;
begin
{$IFDEF JVCLThemesEnabled}
Result := not (CheckWin32Version(5, 1) and StyleServices.Enabled);
Result := not (JclCheckWinVersion(5, 1) and StyleServices.Enabled);
{$ELSE}
Result := True;
{$ENDIF JVCLThemesEnabled}
Expand All @@ -172,7 +175,7 @@ procedure TJvExCustomMaskEdit.DoSetTextHint(const Value: string);
inherited DoSetTextHint(Value);
{$ELSE}
{$IFDEF JVCLThemesEnabled}
if CheckWin32Version(5, 1) and StyleServices.Enabled and HandleAllocated then
if JclCheckWinVersion(5, 1) and StyleServices.Enabled and HandleAllocated then
SendMessage(Handle, EM_SETCUEBANNER, WPARAM(0), LPARAM(PWideChar(UnicodeString(Value))));
{$ENDIF JVCLThemesEnabled}
{$ENDIF COMPILER12_UP}
Expand Down Expand Up @@ -259,7 +262,7 @@ procedure TJvExMaskEdit.CreateWnd;
function TJvExMaskEdit.UserTextHint: Boolean;
begin
{$IFDEF JVCLThemesEnabled}
Result := not (CheckWin32Version(5, 1) and StyleServices.Enabled);
Result := not (JclCheckWinVersion(5, 1) and StyleServices.Enabled);
{$ELSE}
Result := True;
{$ENDIF JVCLThemesEnabled}
Expand All @@ -271,7 +274,7 @@ procedure TJvExMaskEdit.DoSetTextHint(const Value: string);
inherited DoSetTextHint(Value);
{$ELSE}
{$IFDEF JVCLThemesEnabled}
if CheckWin32Version(5, 1) and StyleServices.Enabled and HandleAllocated then
if JclCheckWinVersion(5, 1) and StyleServices.Enabled and HandleAllocated then
SendMessage(Handle, EM_SETCUEBANNER, WPARAM(0), LPARAM(PWideChar(UnicodeString(Value))));
{$ENDIF JVCLThemesEnabled}
{$ENDIF COMPILER12_UP}
Expand Down
13 changes: 8 additions & 5 deletions jvcl/devtools/JvExVCL/src/JvExStdCtrls.pas
Expand Up @@ -126,6 +126,9 @@ TJvExCustomComboBox = class(TCustomComboBox, IJvExControl)

implementation

uses
JclSysInfo;

{$IFNDEF COMPILER12_UP}
const
ECM_FIRST = $1500;
Expand Down Expand Up @@ -178,7 +181,7 @@ procedure TJvExCustomEdit.CreateWnd;
function TJvExCustomEdit.UserTextHint: Boolean;
begin
{$IFDEF JVCLThemesEnabled}
Result := not (CheckWin32Version(5, 1) and StyleServices.Enabled);
Result := not (JclCheckWinVersion(5, 1) and StyleServices.Enabled);
{$ELSE}
Result := True;
{$ENDIF JVCLThemesEnabled}
Expand All @@ -190,7 +193,7 @@ procedure TJvExCustomEdit.DoSetTextHint(const Value: string);
inherited DoSetTextHint(Value);
{$ELSE}
{$IFDEF JVCLThemesEnabled}
if CheckWin32Version(5, 1) and StyleServices.Enabled and HandleAllocated then
if JclCheckWinVersion(5, 1) and StyleServices.Enabled and HandleAllocated then
SendMessage(Handle, EM_SETCUEBANNER, WPARAM(0), LPARAM(PWideChar(UnicodeString(Value))));
{$ENDIF JVCLThemesEnabled}
{$ENDIF COMPILER12_UP}
Expand Down Expand Up @@ -269,7 +272,7 @@ procedure TJvExCustomComboBox.CreateWnd;
function TJvExCustomComboBox.UserTextHint: Boolean;
begin
{$IFDEF JVCLThemesEnabled}
Result := not (CheckWin32Version(5, 1) and StyleServices.Enabled);
Result := not (JclCheckWinVersion(5, 1) and StyleServices.Enabled);
{$ELSE}
Result := True;
{$ENDIF JVCLThemesEnabled}
Expand All @@ -288,9 +291,9 @@ procedure TJvExCustomComboBox.DoSetTextHint;
{$IFDEF JVCLThemesEnabled}
if StyleServices.Enabled and HandleAllocated then
begin
if CheckWin32Version(6) then
if JclCheckWinVersion(6, 0) then
SendMessage(Handle, CB_SETCUEBANNER, WPARAM(0), LPARAM(PWideChar(UnicodeString(FTextHint))))
else if CheckWin32Version(5, 1) then
else if JclCheckWinVersion(5, 1) then
SendMessage(FEditHandle, EM_SETCUEBANNER, WPARAM(0), LPARAM(PWideChar(UnicodeString(FTextHint))));
end;
{$ENDIF JVCLThemesEnabled}
Expand Down
5 changes: 3 additions & 2 deletions jvcl/run/Hid.pas
Expand Up @@ -2161,6 +2161,7 @@ implementation

uses
SysUtils,
JclSysInfo,
ModuleLoader;

{$IFDEF HID_LINKONREQUEST}
Expand Down Expand Up @@ -2232,7 +2233,7 @@ function LoadHid: Boolean;
@HidD_GetSerialNumberString := GetModuleSymbolEx(HidLib, 'HidD_GetSerialNumberString', Result);
@HidD_GetPhysicalDescriptor := GetModuleSymbolEx(HidLib, 'HidD_GetPhysicalDescriptor', Result);
@HidD_GetIndexedString := GetModuleSymbolEx(HidLib, 'HidD_GetIndexedString', Result);
if (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(5, 1) then
if (Win32Platform = VER_PLATFORM_WIN32_NT) and JclCheckWinVersion(5, 1) then
begin
@HidD_GetInputReport := GetModuleSymbolEx(HidLib, 'HidD_GetInputReport', Result);
@HidD_SetOutputReport := GetModuleSymbolEx(HidLib, 'HidD_SetOutputReport', Result);
Expand Down Expand Up @@ -2262,7 +2263,7 @@ function LoadHid: Boolean;
@HidP_SetUsageValueArray := GetModuleSymbolEx(HidLib, 'HidP_SetUsageValueArray', Result);
@HidP_UsageListDifference := GetModuleSymbolEx(HidLib, 'HidP_UsageListDifference', Result);
@HidP_TranslateUsagesToI8042ScanCodes := GetModuleSymbolEx(HidLib, 'HidP_TranslateUsagesToI8042ScanCodes', Result);
if (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(5, 0) then
if (Win32Platform = VER_PLATFORM_WIN32_NT) and JclCheckWinVersion(5, 0) then
begin
@HidP_GetExtendedAttributes := GetModuleSymbolEx(HidLib, 'HidP_GetExtendedAttributes', Result);
@HidP_InitializeReportForID := GetModuleSymbolEx(HidLib, 'HidP_InitializeReportForID', Result);
Expand Down
7 changes: 4 additions & 3 deletions jvcl/run/JvBalloonHint.pas
Expand Up @@ -313,6 +313,7 @@ implementation
Types,
{$ENDIF SUPPORTS_INLINE}
ComCtrls, // needed for GetComCtlVersion
JclSysInfo,
{$IFNDEF COMPILER12_UP}
JvJCLUtils,
{$ENDIF ~COMPILER12_UP}
Expand Down Expand Up @@ -407,17 +408,17 @@ function DesktopRect: TRect;

function IsWinXP_UP: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(5, 1);
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and JclCheckWinVersion(5, 1);
end;

function IsWinVista_UP: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(6, 0);
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and JclCheckWinVersion(6, 0);
end;

function IsWinSeven_UP: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(6, 1);
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and JclCheckWinVersion(6, 1);
end;

function InternalClientToParent(AControl: TControl; const Point: TPoint;
Expand Down
3 changes: 2 additions & 1 deletion jvcl/run/JvCaptionButton.pas
Expand Up @@ -312,6 +312,7 @@ implementation

uses
CommCtrl, Buttons, SysUtils,
JclSysInfo,
JvThemes,
{$IFDEF JVCLThemesEnabled}
UxTheme,
Expand Down Expand Up @@ -439,7 +440,7 @@ TGlobalXPData = class(TObject)

function IsVistaOrNewer: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(6, 0);
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and JclCheckWinVersion(6, 0);
end;

function GlobalXPData: TGlobalXPData;
Expand Down
3 changes: 2 additions & 1 deletion jvcl/run/JvComCtrls.pas
Expand Up @@ -44,6 +44,7 @@ interface
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
JclSysInfo,
Windows, Messages, Graphics, Controls, Forms,
Classes,
Menus, ComCtrls, ImgList, Buttons, Types, CommCtrl,
Expand Down Expand Up @@ -729,7 +730,7 @@ function NeedCheckStateEmulation(): Boolean; // ComCtrls 6+ under Vista+
ComCtlVersionIE6 = $00060000;
{$ENDIF ~COMPILER7_UP}
begin
Result := (GetComCtlVersion < ComCtlVersionIE6) or not CheckWin32Version(6, 0);
Result := (GetComCtlVersion < ComCtlVersionIE6) or not JclCheckWinVersion(6, 0);
end;

//=== { TJvIPAddressRange } ==================================================
Expand Down
3 changes: 2 additions & 1 deletion jvcl/run/JvDBLookup.pas
Expand Up @@ -689,6 +689,7 @@ implementation

uses
VDBConsts, DBConsts, SysUtils, Math, MultiMon,
JclSysInfo,
JvJCLUtils, JvJVCLUtils, JvThemes, JvTypes, JvConsts, JvResources, JclSysUtils;

procedure CheckLookupFormat(const AFormat: string);
Expand Down Expand Up @@ -2401,7 +2402,7 @@ procedure TJvPopupDataList.CreateParams(var Params: TCreateParams);
ExStyle := WS_EX_TOOLWINDOW;
AddBiDiModeExStyle(ExStyle);
WindowClass.Style := CS_SAVEBITS;
if CheckWin32Version(5, 1) then // Windows XP+
if JclCheckWinVersion(5, 1) then // Windows XP+
WindowClass.Style := WindowClass.Style or CS_DROPSHADOW;
end;
end;
Expand Down
3 changes: 2 additions & 1 deletion jvcl/run/JvDateTimePicker.pas
Expand Up @@ -114,6 +114,7 @@ implementation
uses
CommCtrl,
Types,
JclSysInfo,
JvThemes;

{$IFNDEF COMPILER7_UP}
Expand Down Expand Up @@ -264,7 +265,7 @@ function IsBlankSysTime(const St: TSystemTime): Boolean;

function IsWinVista_UP: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(6, 0);
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and JclCheckWinVersion(6, 0);
end;

procedure TJvDateTimePicker.UpdateCalendar(CalHandle: THandle);
Expand Down
2 changes: 1 addition & 1 deletion jvcl/run/JvDialogs.pas
Expand Up @@ -169,7 +169,7 @@ implementation

function IsWin2kOrAbove: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(5, 0);
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and JclCheckWinVersion(5, 0);
end;

procedure UninstallW2kFix;
Expand Down
3 changes: 2 additions & 1 deletion jvcl/run/JvDockControlForm.pas
Expand Up @@ -877,6 +877,7 @@ implementation

uses
Types, SysUtils,
JclSysInfo,
JvAppRegistryStorage, JvAppIniStorage, JvTypes,
JvDockSupportProc, JvDockGlobals, JvDockInfo, JvDockVSNetStyle, JvJVCLUtils;

Expand All @@ -901,7 +902,7 @@ TWinControlAccessProtected = class(TWinControl);

function IsWinXP_UP: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(5, 1);
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and JclCheckWinVersion(5, 1);
end;

procedure ApplyShowingChanged;
Expand Down
5 changes: 3 additions & 2 deletions jvcl/run/JvEditorCommon.pas
Expand Up @@ -1399,6 +1399,7 @@ implementation
Types,
{$ENDIF SUPPORTS_INLINE}
RTLConsts, Math, Clipbrd,
JclSysInfo,
JvJCLUtils, JvThemes, JvResources;

type
Expand All @@ -1425,7 +1426,7 @@ TJvEditorCompletionList = class(TListBox)

function KeyPressed(VK: Integer): Boolean;
begin
Result := GetKeyState(VK) and $8000 = $8000;
Result := Windows.GetKeyState(VK) and $8000 = $8000;
end;

//=== { TJvUndoBuffer } ======================================================
Expand Down Expand Up @@ -3258,7 +3259,7 @@ procedure TJvCustomEditorBase.Scroll(Vert: Boolean; ScrollPos: Integer);
@RUpdate // address of structure for update rectangle
);
// (ahuser) WinNT seams to have problems with ScrollDC in vertical direction. (Mantis #2528)
if (Win32Platform = VER_PLATFORM_WIN32_NT) and not CheckWin32Version(5, 0) then
if (Win32Platform = VER_PLATFORM_WIN32_NT) and not JclCheckWinVersion(5, 0) then
Dec(RUpdate.Top, CellRect.Height);
Inc(RUpdate.Bottom, CellRect.Height);
Windows.InvalidateRect(Handle, @RUpdate, False);
Expand Down
11 changes: 7 additions & 4 deletions jvcl/run/JvExMask.pas
Expand Up @@ -238,6 +238,9 @@ TJvExMaskEdit = class(TMaskEdit, IJvExControl)

implementation

uses
JclSysInfo;

{$IFNDEF COMPILER12_UP}
const
ECM_FIRST = $1500;
Expand Down Expand Up @@ -603,7 +606,7 @@ procedure TJvExCustomMaskEdit.CreateWnd;
function TJvExCustomMaskEdit.UserTextHint: Boolean;
begin
{$IFDEF JVCLThemesEnabled}
Result := not (CheckWin32Version(5, 1) and StyleServices.Enabled);
Result := not (JclCheckWinVersion(5, 1) and StyleServices.Enabled);
{$ELSE}
Result := True;
{$ENDIF JVCLThemesEnabled}
Expand All @@ -615,7 +618,7 @@ procedure TJvExCustomMaskEdit.DoSetTextHint(const Value: string);
inherited DoSetTextHint(Value);
{$ELSE}
{$IFDEF JVCLThemesEnabled}
if CheckWin32Version(5, 1) and StyleServices.Enabled and HandleAllocated then
if JclCheckWinVersion(5, 1) and StyleServices.Enabled and HandleAllocated then
SendMessage(Handle, EM_SETCUEBANNER, WPARAM(0), LPARAM(PWideChar(UnicodeString(Value))));
{$ENDIF JVCLThemesEnabled}
{$ENDIF COMPILER12_UP}
Expand Down Expand Up @@ -1013,7 +1016,7 @@ procedure TJvExMaskEdit.CreateWnd;
function TJvExMaskEdit.UserTextHint: Boolean;
begin
{$IFDEF JVCLThemesEnabled}
Result := not (CheckWin32Version(5, 1) and StyleServices.Enabled);
Result := not (JclCheckWinVersion(5, 1) and StyleServices.Enabled);
{$ELSE}
Result := True;
{$ENDIF JVCLThemesEnabled}
Expand All @@ -1025,7 +1028,7 @@ procedure TJvExMaskEdit.DoSetTextHint(const Value: string);
inherited DoSetTextHint(Value);
{$ELSE}
{$IFDEF JVCLThemesEnabled}
if CheckWin32Version(5, 1) and StyleServices.Enabled and HandleAllocated then
if JclCheckWinVersion(5, 1) and StyleServices.Enabled and HandleAllocated then
SendMessage(Handle, EM_SETCUEBANNER, WPARAM(0), LPARAM(PWideChar(UnicodeString(Value))));
{$ENDIF JVCLThemesEnabled}
{$ENDIF COMPILER12_UP}
Expand Down
13 changes: 8 additions & 5 deletions jvcl/run/JvExStdCtrls.pas
Expand Up @@ -1114,6 +1114,9 @@ TJvExStaticText = class(TStaticText, IJvExControl)

implementation

uses
JclSysInfo;

{$IFNDEF COMPILER12_UP}
const
ECM_FIRST = $1500;
Expand Down Expand Up @@ -2060,7 +2063,7 @@ procedure TJvExCustomEdit.CreateWnd;
function TJvExCustomEdit.UserTextHint: Boolean;
begin
{$IFDEF JVCLThemesEnabled}
Result := not (CheckWin32Version(5, 1) and StyleServices.Enabled);
Result := not (JclCheckWinVersion(5, 1) and StyleServices.Enabled);
{$ELSE}
Result := True;
{$ENDIF JVCLThemesEnabled}
Expand All @@ -2072,7 +2075,7 @@ procedure TJvExCustomEdit.DoSetTextHint(const Value: string);
inherited DoSetTextHint(Value);
{$ELSE}
{$IFDEF JVCLThemesEnabled}
if CheckWin32Version(5, 1) and StyleServices.Enabled and HandleAllocated then
if JclCheckWinVersion(5, 1) and StyleServices.Enabled and HandleAllocated then
SendMessage(Handle, EM_SETCUEBANNER, WPARAM(0), LPARAM(PWideChar(UnicodeString(Value))));
{$ENDIF JVCLThemesEnabled}
{$ENDIF COMPILER12_UP}
Expand Down Expand Up @@ -3036,7 +3039,7 @@ procedure TJvExCustomComboBox.CreateWnd;
function TJvExCustomComboBox.UserTextHint: Boolean;
begin
{$IFDEF JVCLThemesEnabled}
Result := not (CheckWin32Version(5, 1) and StyleServices.Enabled);
Result := not (JclCheckWinVersion(5, 1) and StyleServices.Enabled);
{$ELSE}
Result := True;
{$ENDIF JVCLThemesEnabled}
Expand All @@ -3055,9 +3058,9 @@ procedure TJvExCustomComboBox.DoSetTextHint;
{$IFDEF JVCLThemesEnabled}
if StyleServices.Enabled and HandleAllocated then
begin
if CheckWin32Version(6) then
if JclCheckWinVersion(6, 0) then
SendMessage(Handle, CB_SETCUEBANNER, WPARAM(0), LPARAM(PWideChar(UnicodeString(FTextHint))))
else if CheckWin32Version(5, 1) then
else if JclCheckWinVersion(5, 1) then
SendMessage(FEditHandle, EM_SETCUEBANNER, WPARAM(0), LPARAM(PWideChar(UnicodeString(FTextHint))));
end;
{$ENDIF JVCLThemesEnabled}
Expand Down
3 changes: 2 additions & 1 deletion jvcl/run/JvListView.pas
Expand Up @@ -539,6 +539,7 @@ implementation
AnsiStrings,
{$ENDIF RTL250_UP}
VarUtils, Variants,
JclSysInfo,
JvConsts;

type
Expand Down Expand Up @@ -2249,7 +2250,7 @@ function TJvListView.CustomDrawItem(Item: TListItem;
Canvas.Font := TJvListItem(Item).Font;
if ViewStyle in ViewStylesItemBrush then
begin
if CheckWin32Version(6, 0) then
if JclCheckWinVersion(6, 0) then
SetBkMode(Canvas.Handle, TRANSPARENT);
Canvas.Brush := TJvListItem(Item).Brush;
end;
Expand Down
4 changes: 2 additions & 2 deletions jvcl/run/JvMenus.pas
Expand Up @@ -782,7 +782,7 @@ implementation
{$IFNDEF COMPILER7_UP}
JvWin32,
{$ENDIF ~COMPILER7_UP}
JclGraphUtils, JvConsts, JvJCLUtils, JvJVCLUtils;
JclSysInfo, JclGraphUtils, JvConsts, JvJCLUtils, JvJVCLUtils;

const
Separator = '-';
Expand Down Expand Up @@ -847,7 +847,7 @@ function IsItemPopup(Item: TMenuItem): Boolean;

function IsWinXP_UP: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(5, 1);
Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and JclCheckWinVersion(5, 1);
end;

function UseFlatMenubars: Boolean;
Expand Down

0 comments on commit 825400a

Please sign in to comment.