如何利用预编译指令来判断Delphi 的版本?
用 {$IFDEF VER1XX} 来判断
// Delphi 4
{$IFDEF VER120}
{$DEFINE VCL4ORABOVE}
{$DEFINE VCL4O}
{$DEFINE DELPHI}
{$DEFINE DELPHI4}
{$DEFINE OVERLOADING}
{$DEFINE OPTIONALPARAMS}
{$ENDIF}
// C++ Builder 4
{$IFDEF VER125}
{$DEFINE VCL4ORABOVE}
{$DEFINE VCL4O}
{$DEFINE CBUILDER}
{$DEFINE CBUILDER4}
{$DEFINE OVERLOADING}
{$DEFINE OPTIONALPARAMS}
{$ENDIF}
// Delphi 5 & CBuilder 5
{$IFDEF VER130}
{$DEFINE VCL4ORABOVE}
{$DEFINE VCL5ORABOVE}
{$DEFINE VCL5O}
{$IFDEF BCB}
{$DEFINE CBUILDER}
{$DEFINE CBUILDER5}
{$ELSE}
{$DEFINE DELPHI}
{$DEFINE DELPHI5}
{$ENDIF}
{$DEFINE OVERLOADING}
{$DEFINE OPTIONALPARAMS}
{$DEFINE SAMETEXT}
{$ENDIF}
//Delphi 6
{$IFDEF VER140}
{$DEFINE VCL4ORABOVE}
{$DEFINE VCL5ORABOVE}
{$IFDEF BCB}
{$DEFINE CBUILDER}
{$DEFINE CBUILDER6}
{$ELSE}
{$DEFINE DELPHI}
{$DEFINE DELPHI6}
{$ENDIF}
{$DEFINE OVERLOADING}
{$DEFINE OPTIONALPARAMS}
{$DEFINE SAMETEXT}
{$DEFINE VCL6ORABOVE}
{$DEFINE VCL6O}
{$ENDIF}
//Delphi 7
{$IFDEF VER150}
{$DEFINE VCL4ORABOVE}
{$DEFINE VCL5ORABOVE}
{$IFDEF BCB}
{$DEFINE CBUILDER}
{$DEFINE CBUILDER7}
{$ELSE}
{$DEFINE DELPHI}
{$DEFINE DELPHI7}
{$ENDIF}
{$DEFINE OVERLOADING}
{$DEFINE OPTIONALPARAMS}
{$DEFINE SAMETEXT}
{$DEFINE VCL6ORABOVE}
{$DEFINE VCL7ORABOVE}
{$DEFINE VCL6O}
{$DEFINE VCL70}
{$ENDIF}
//Delphi 8
{$IFDEF VER160}
{$DEFINE VCL4ORABOVE}
{$DEFINE VCL5ORABOVE}
{$IFDEF BCB}
{$DEFINE CBUILDER}
{$DEFINE CBUILDER8}
{$ELSE}
{$DEFINE DELPHI}
{$DEFINE DELPHI8}
{$ENDIF}
{$DEFINE OVERLOADING}
{$DEFINE OPTIONALPARAMS}
{$DEFINE SAMETEXT}
{$DEFINE VCL6ORABOVE}
{$DEFINE VCL7ORABOVE}
{$DEFINE VCL80RABOVE}
{$DEFINE VCL6O}
{$DEFINE VCL70}
{$DEFINE VCL80}
{$ENDIF}
//Delphi 9
{$IFDEF VER170}
{$DEFINE VCL4ORABOVE}
{$DEFINE VCL5ORABOVE}
{$IFDEF BCB}
{$DEFINE CBUILDER}
{$DEFINE CBUILDER9}
{$ELSE}
{$DEFINE DELPHI}
{$DEFINE DELPHI9}
{$ENDIF}
{$DEFINE OVERLOADING}
{$DEFINE OPTIONALPARAMS}
{$DEFINE SAMETEXT}
{$DEFINE VCL6ORABOVE}
{$DEFINE VCL7ORABOVE}
{$DEFINE VCL80RABOVE}
{$DEFINE VCL9ORABOVE}
{$DEFINE VCL6O}
{$DEFINE VCL70}
{$DEFINE VCL80}
{$DEFINE VCL90}
{$ENDIF}
//Delphi 10
{$IFDEF VER180}
{$DEFINE VCL4ORABOVE}
{$DEFINE VCL5ORABOVE}
{$IFDEF BCB}
{$DEFINE CBUILDER}
{$DEFINE CBUILDER10}
{$ELSE}
{$DEFINE DELPHI}
{$DEFINE DELPHI10}
{$ENDIF}
{$DEFINE OVERLOADING}
{$DEFINE OPTIONALPARAMS}
{$DEFINE SAMETEXT}
{$DEFINE VCL6ORABOVE}
{$DEFINE VCL7ORABOVE}
{$DEFINE VCL80RABOVE}
{$DEFINE VCL9ORABOVE}
{$DEFINE VCL1O0RABOVE}
{$DEFINE VCL6O}
{$DEFINE VCL70}
{$DEFINE VCL80}
{$DEFINE VCL90}
{$DEFINE VCL100}
{$ENDIF}
{$IFDEF LINUX}
{$DEFINE VCL4ORABOVE}
{$DEFINE VCL5ORABOVE}
{$DEFINE OVERLOADING}
{$DEFINE OPTIONALPARAMS}
{$DEFINE SAMETEXT}
{$DEFINE VCL6ORABOVE}
{$DEFINE VCL6O}
{$UNDEF DELPHI6}
{$DEFINE KYLIX}
{$IFDEF CONDITIONALEXPRESSIONS}
{$IF RTLVersion = 14.0}
{$DEFINE KYLIX2}
{$IFEND}
{$IF RTLVersion = 14.50}
{$DEFINE KYLIX3}
{$IFDEF BCB}
{$DEFINE BCBKYLIX3}
{$ENDIF}
{$IFEND}
{$IF RTLVersion = 15.0}
{$DEFINE KYLIX4}
{$IFEND}
{$ENDIF}
{$ENDIF}