📄 jclborlandtools.pas
字号:
{**************************************************************************************************}
{ }
{ Project JEDI Code Library (JCL) }
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the }
{ License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
{ ANY KIND, either express or implied. See the License for the specific language governing rights }
{ and limitations under the License. }
{ }
{ The Original Code is DelphiInstall.pas. }
{ }
{ The Initial Developer of the Original Code is Petr Vones. Portions created by Petr Vones are }
{ Copyright (C) of Petr Vones. All Rights Reserved. }
{ }
{ Contributor(s): }
{ Andreas Hausladen (ahuser) }
{ Robert Rossmair (rrossmair) - crossplatform & BCB support }
{ }
{**************************************************************************************************}
{ }
{ Routines for getting information about installed versions of Delphi/C++Builder and performing }
{ basic installation tasks. }
{ }
{ Unit owner: Petr Vones }
{ }
{**************************************************************************************************}
// Last modified: $Date: 2005/03/08 08:33:15 $
unit JclBorlandTools;
{$I jcl.inc}
{$I crossplatform.inc}
interface
uses
{$IFDEF MSWINDOWS}
Windows,
{$ENDIF MSWINDOWS}
Classes, SysUtils, IniFiles, Contnrs,
JclBase, JclSysUtils;
// Various definitions
type
TJclBorRADToolKind = (brDelphi, brCppBuilder); //, brBorlandDevStudio);
{$IFDEF KYLIX}
TJclBorRADToolEdition = (deOPEN, dePRO, deSVR);
{$ELSE}
TJclBorRADToolEdition = (deSTD, dePRO, deCSS, deARC);
{$ENDIF KYLIX}
TJclBorRADToolPath = string;
const
SupportedDelphiVersions = [5, 6, 7, 9];
SupportedBCBVersions = [5, 6];
// Object Repository
BorRADToolRepositoryPagesSection = 'Repository Pages';
BorRADToolRepositoryDialogsPage = 'Dialogs';
BorRADToolRepositoryFormsPage = 'Forms';
BorRADToolRepositoryProjectsPage = 'Projects';
BorRADToolRepositoryDataModulesPage = 'Data Modules';
BorRADToolRepositoryObjectType = 'Type';
BorRADToolRepositoryFormTemplate = 'FormTemplate';
BorRADToolRepositoryProjectTemplate = 'ProjectTemplate';
BorRADToolRepositoryObjectName = 'Name';
BorRADToolRepositoryObjectPage = 'Page';
BorRADToolRepositoryObjectIcon = 'Icon';
BorRADToolRepositoryObjectDescr = 'Description';
BorRADToolRepositoryObjectAuthor = 'Author';
BorRADToolRepositoryObjectAncestor = 'Ancestor';
BorRADToolRepositoryObjectDesigner = 'Designer'; // Delphi 6+ only
BorRADToolRepositoryDesignerDfm = 'dfm';
BorRADToolRepositoryDesignerXfm = 'xfm';
BorRADToolRepositoryObjectNewForm = 'DefaultNewForm';
BorRADToolRepositoryObjectMainForm = 'DefaultMainForm';
{$IFDEF KYLIX}
BorRADToolEditionIDs: array [TJclBorRADToolEdition] of PChar =
('OPEN', 'PRO', 'SVR');
{$ELSE ~KYLIX}
BorRADToolEditionIDs: array [TJclBorRADToolEdition] of PChar =
('STD', 'PRO', 'CSS', 'ARC'); // 'ARC' is an assumption
{$ENDIF ~KYLIX}
// Installed versions information classes
type
TJclBorRADToolInstallation = class;
TJclBorRADToolInstallationObject = class(TInterfacedObject)
private
FInstallation: TJclBorRADToolInstallation;
protected
constructor Create(AInstallation: TJclBorRADToolInstallation);
public
property Installation: TJclBorRADToolInstallation read FInstallation;
end;
{$IFDEF MSWINDOWS}
TJclBorlandOpenHelp = class(TJclBorRADToolInstallationObject)
private
function GetContentFileName: string;
function GetIndexFileName: string;
function GetLinkFileName: string;
function GetGidFileName: string;
function GetProjectFileName: string;
function ReadFileName(const FormatName: string): string;
public
function AddHelpFile(const HelpFileName, IndexName: string): Boolean;
function RemoveHelpFile(const HelpFileName, IndexName: string): Boolean;
property ContentFileName: string read GetContentFileName;
property GidFileName: string read GetGidFileName;
property IndexFileName: string read GetIndexFileName;
property LinkFileName: string read GetLinkFileName;
property ProjectFileName: string read GetProjectFileName;
end;
{$ENDIF MSWINDOWS}
TJclBorRADToolIdeTool = class(TJclBorRADToolInstallationObject)
private
FKey: string;
function GetCount: Integer;
function GetParameters(Index: Integer): string;
function GetPath(Index: Integer): string;
function GetTitle(Index: Integer): string;
function GetWorkingDir(Index: Integer): string;
procedure SetCount(const Value: Integer);
procedure SetParameters(Index: Integer; const Value: string);
procedure SetPath(Index: Integer; const Value: string);
procedure SetTitle(Index: Integer; const Value: string);
procedure SetWorkingDir(Index: Integer; const Value: string);
protected
constructor Create(AInstallation: TJclBorRADToolInstallation);
procedure CheckIndex(Index: Integer);
public
property Count: Integer read GetCount write SetCount;
function IndexOfPath(const Value: string): Integer;
function IndexOfTitle(const Value: string): Integer;
property Key: string read FKey;
property Title[Index: Integer]: string read GetTitle write SetTitle;
property Path[Index: Integer]: string read GetPath write SetPath;
property Parameters[Index: Integer]: string read GetParameters write SetParameters;
property WorkingDir[Index: Integer]: string read GetWorkingDir write SetWorkingDir;
end;
TJclBorRADToolIdePackages = class(TJclBorRADToolInstallationObject)
private
FDisabledPackages: TStringList;
FKnownPackages: TStringList;
function GetCount: Integer;
function GetPackageDescriptions(Index: Integer): string;
function GetPackageDisabled(Index: Integer): Boolean;
function GetPackageFileNames(Index: Integer): string;
protected
constructor Create(AInstallation: TJclBorRADToolInstallation);
function PackageEntryToFileName(const Entry: string): string;
procedure ReadPackages;
procedure RemoveDisabled(const FileName: string);
public
destructor Destroy; override;
function AddPackage(const FileName, Description: string): Boolean;
function RemovePackage(const FileName: string): Boolean;
property Count: Integer read GetCount;
property PackageDescriptions[Index: Integer]: string read GetPackageDescriptions;
property PackageFileNames[Index: Integer]: string read GetPackageFileNames;
property PackageDisabled[Index: Integer]: Boolean read GetPackageDisabled;
end;
IJclCommandLineTool = interface
['{A0034B09-A074-D811-847D-0030849E4592}']
function GetExeName: string;
function GetOptions: TStrings;
function GetOutput: string;
function GetOutputCallback: TTextHandler;
procedure AddPathOption(const Option, Path: string);
function Execute(const CommandLine: string): Boolean;
procedure SetOutputCallback(const CallbackMethod: TTextHandler);
property ExeName: string read GetExeName;
property Options: TStrings read GetOptions;
property OutputCallback: TTextHandler write SetOutputCallback;
property Output: string read GetOutput;
end;
EJclCommandLineToolError = class(EJclError);
TJclCommandLineTool = class(TInterfacedObject, IJclCommandLineTool)
private
FExeName: string;
FOptions: TStringList;
FOutput: string;
FOutputCallback: TTextHandler;
protected
function GetExeName: string;
function GetOutput: string;
function GetOptions: TStrings;
function GetOutputCallback: TTextHandler;
procedure SetOutputCallback(const CallbackMethod: TTextHandler);
constructor Create(const AExeName: string);
procedure AddPathOption(const Option, Path: string);
function Execute(const CommandLine: string): Boolean;
property ExeName: string read GetExeName;
property Output: string read GetOutput;
public
destructor Destroy; override;
end;
TJclBorlandCommandLineTool = class(TJclBorRADToolInstallationObject, IJclCommandLineTool)
private
FOptions: TStringList;
FOutputCallback: TTextHandler;
FOutput: string;
protected
constructor Create(AInstallation: TJclBorRADToolInstallation); virtual;
procedure CheckOutputValid;
function GetExeName: string; virtual;
function GetFileName: string;
function GetOptions: TStrings;
function GetOutputCallback: TTextHandler;
procedure SetOutputCallback(const CallbackMethod: TTextHandler);
function GetOutput: string;
public
destructor Destroy; override;
procedure AddPathOption(const Option, Path: string);
function Execute(const CommandLine: string): Boolean; virtual;
property FileName: string read GetFileName;
property Output: string read GetOutput;
property OutputCallback: TTextHandler read FOutputCallback write SetOutputCallback;
property Options: TStrings read GetOptions;
end;
TJclDCC = class(TJclBorlandCommandLineTool)
protected
constructor Create(AInstallation: TJclBorRADToolInstallation); override;
function GetExeName: string; override;
public
function Execute(const CommandLine: string): Boolean; override;
function MakePackage(const PackageName, BPLPath, DCPPath: string): Boolean;
procedure SetDefaultOptions;
function SupportsLibSuffix: Boolean;
end;
TJclBpr2Mak = class(TJclBorlandCommandLineTool)
protected
function GetExeName: string; override;
end;
TJclBorlandMake = class(TJclBorlandCommandLineTool)
protected
function GetExeName: string; override;
end;
TJclBorRADToolPalette = class(TJclBorRADToolInstallationObject)
private
FKey: string;
FTabNames: TStringList;
function GetComponentsOnTab(Index: Integer): string;
function GetHiddenComponentsOnTab(Index: Integer): string;
function GetTabNameCount: Integer;
function GetTabNames(Index: Integer): string;
procedure ReadTabNames;
protected
constructor Create(AInstallation: TJclBorRADToolInstallation);
public
destructor Destroy; override;
procedure ComponentsOnTabToStrings(Index: Integer; Strings: TStrings; IncludeUnitName: Boolean = False;
IncludeHiddenComponents: Boolean = True);
function DeleteTabName(const TabName: string): Boolean;
function TabNameExists(const TabName: string): Boolean;
property ComponentsOnTab[Index: Integer]: string read GetComponentsOnTab;
property HiddenComponentsOnTab[Index: Integer]: string read GetHiddenComponentsOnTab;
property Key: string read FKey;
property TabNames[Index: Integer]: string read GetTabNames;
property TabNameCount: Integer read GetTabNameCount;
end;
TJclBorRADToolRepository = class(TJclBorRADToolInstallationObject)
private
FIniFile: TIniFile;
FFileName: string;
FPages: TStringList;
function GetIniFile: TIniFile;
function GetPages: TStrings;
protected
constructor Create(AInstallation: TJclBorRADToolInstallation);
public
destructor Destroy; override;
procedure AddObject(const FileName, ObjectType, PageName, ObjectName, IconFileName, Description,
Author, Designer: string; const Ancestor: string = '');
procedure CloseIniFile;
function FindPage(const Name: string; OptionalIndex: Integer): string;
procedure RemoveObjects(const PartialPath, FileName, ObjectType: string);
property FileName: string read FFileName;
property IniFile: TIniFile read GetIniFile;
property Pages: TStrings read GetPages;
end;
TJclBorRADToolInstallationClass = class of TJclBorRADToolInstallation;
TJclBorRADToolInstallation = class(TObject)
private
FConfigData: TCustomIniFile;
FGlobals: TStringList;
FRootDir: string;
FBinFolderName: string;
FDCC: TJclDCC;
FMake: IJclCommandLineTool;
FEditionStr: string;
FEdition: TJclBorRADToolEdition;
FEnvironmentVariables: TStringList;
FIdePackages: TJclBorRADToolIdePackages;
FIdeTools: TJclBorRADToolIdeTool;
FInstalledUpdatePack: Integer;
{$IFDEF MSWINDOWS}
FOpenHelp: TJclBorlandOpenHelp;
{$ENDIF MSWINDOWS}
FPalette: TJclBorRADToolPalette;
FRepository: TJclBorRADToolRepository;
FVersionNumber: Integer;
FVersionNumberStr: string;
FIDEVersionNumber: Integer; // Delphi 2005: 3 - Delphi 7: 7
function GetBPLOutputPath: string;
function GetDCC: TJclDCC;
function GetDCPOutputPath: string;
function GetDebugDCUPath: string;
function GetDefaultProjectsDir: string;
function GetDescription: string;
function GetEditionAsText: string;
function GetEnvironmentVariables: TStrings;
function GetIdeExeFileName: string;
function GetGlobals: TStrings;
function GetIdeExeBuildNumber: string;
function GetIdePackages: TJclBorRADToolIdePackages;
function GetLatestUpdatePack: Integer;
function GetLibrarySearchPath: TJclBorRADToolPath;
function GetName: string;
function GetPalette: TJclBorRADToolPalette;
function GetRepository: TJclBorRADToolRepository;
function GetUpdateNeeded: Boolean;
function GetValid: Boolean;
procedure SetLibrarySearchPath(const Value: TJclBorRADToolPath);
function GetLibraryBrowsingPath: TJclBorRADToolPath;
procedure SetLibraryBrowsingPath(const Value: TJclBorRADToolPath);
procedure SetDebugDCUPath(const Value: string);
protected
constructor Create(const AConfigDataLocation: string); virtual;
{$IFDEF MSWINDOWS}
function GetBorlandStudioProjectsDir: string;
{$ENDIF MSWINDOWS}
procedure ReadInformation;
function AddMissingPathItems(var Path: string; const NewPath: string): Boolean;
function RemoveFromPath(var Path: string; const ItemsToRemove: string): Boolean;
public
destructor Destroy; override;
class procedure ExtractPaths(const Path: TJclBorRADToolPath; List: TStrings);
class function GetLatestUpdatePackForVersion(Version: Integer): Integer; virtual;
class function PackageSourceFileExtension: string; virtual;
class function RadToolKind: TJclBorRadToolKind; virtual;
class function RadToolName: string; virtual;
function AnyInstanceRunning: Boolean;
function AddToDebugDCUPath(const Path: string): Boolean;
function AddToLibrarySearchPath(const Path: string): Boolean;
function AddToLibraryBrowsingPath(const Path: string): Boolean;
{$IFDEF KYLIX}
function ConfigFileName(const Extension: string): string; virtual;
{$ENDIF KYLIX}
function FindFolderInPath(Folder: string; List: TStrings): Integer;
function InstallPackage(const PackageName, BPLPath, DCPPath: string): Boolean; virtual;
function IsBDSPersonality: Boolean;
function LibFolderName: string;
function RemoveFromDebugDCUPath(const Path: string): Boolean;
function RemoveFromLibrarySearchPath(const Path: string): Boolean;
function RemoveFromLibraryBrowsingPath(const Path: string): Boolean;
function SubstitutePath(const Path: string): string;
function SupportsVisualCLX: Boolean;
function UninstallPackage(const PackageName, BPLPath, DCPPath: string): Boolean;
property BinFolderName: string read FBinFolderName;
property BPLOutputPath: string read GetBPLOutputPath;
property DCC: TJclDCC read GetDCC;
property DebugDCUPath: string read GetDebugDCUPath write SetDebugDCUPath;
property DCPOutputPath: string read GetDCPOutputPath;
property DefaultProjectsDir: string read GetDefaultProjectsDir;
property Description: string read GetDescription;
property Edition: TJclBorRADToolEdition read FEdition;
property EditionAsText: string read GetEditionAsText;
property EnvironmentVariables: TStrings read GetEnvironmentVariables;
property IdePackages: TJclBorRADToolIdePackages read GetIdePackages;
property IdeTools: TJclBorRADToolIdeTool read FIdeTools;
property IdeExeBuildNumber: string read GetIdeExeBuildNumber;
property IdeExeFileName: string read GetIdeExeFileName;
property InstalledUpdatePack: Integer read FInstalledUpdatePack;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -