Delphi OpenTools API - 编辑项目需要子句
Delphi OpenTools API - Editing the project requires clause
我编写了一个 OpenTools 向导,用于为自定义项目类型创建骨架。它确实有效,并且正确创建了项目和单元。但是,如何编辑 .dpk 或 .dpk 文件的 requires 子句?
调用 ModuleServices.CreateModule(MyIOTAProjectCreatorInterface)
只给我 .dproj 文件。
在我的VCL Component Installer中(从XE开始,这是DelphiIDE的一部分),我是这样做的:
procedure TCompInstallWizard.AddReferenceFiles(InstallProject: IOTAProject;
const FileNames: array of string);
var
ReferenceFile: string;
begin
WriteDebugMessage('AddReferenceFiles');
for ReferenceFile in FileNames do
if not ContainsFile(InstallProject, ReferenceFile) then
InstallProject.AddFile(ReferenceFile, False);
end;
借助函数 IOTAProject.AddFile(FileName, IsUnitOrForm)
。请注意,我这样称呼它:
if FPersonality = ppCppBuilder then
AddReferenceFiles(InstallProject,
['rtl.bpi', 'designide.bpi', 'vcl.bpi', 'vclactnband.bpi',
'vclx.bpi', 'xmlrtl.bpi'])
else
AddReferenceFiles(InstallProject,
['rtl.dcp', 'designide.dcp', 'vcl.dcp', 'vclactnband.dcp',
'vclx.dcp', 'xmlrtl.dcp']);
请注意文档说:
{ Call this function to add an arbitrary file to the project. NOTE: some
files have special meaning to different projects. For example: adding
VCL60.DCP will cause a new entry in a package project's "requires" list
while it will be a raw file to any other project type. Set IsUnitOrForm
to true for files that are considered items that the project would
process directly or indirectly (ie. .pas, .cpp, .rc, etc..) or can be
opened in the code editor. For all others, including binary files
(.res, .bpi, .dcp, etc..) set this to False. }
procedure AddFile(const AFileName: string; IsUnitOrForm: Boolean);
这意味着如果你添加一个'bla.dcp'
它会自动落在requires
部分,如果你添加一个'bla.pas'
文件它会落在[=17] =] 部分。我花了一段时间才知道。
我编写了一个 OpenTools 向导,用于为自定义项目类型创建骨架。它确实有效,并且正确创建了项目和单元。但是,如何编辑 .dpk 或 .dpk 文件的 requires 子句?
调用 ModuleServices.CreateModule(MyIOTAProjectCreatorInterface)
只给我 .dproj 文件。
在我的VCL Component Installer中(从XE开始,这是DelphiIDE的一部分),我是这样做的:
procedure TCompInstallWizard.AddReferenceFiles(InstallProject: IOTAProject;
const FileNames: array of string);
var
ReferenceFile: string;
begin
WriteDebugMessage('AddReferenceFiles');
for ReferenceFile in FileNames do
if not ContainsFile(InstallProject, ReferenceFile) then
InstallProject.AddFile(ReferenceFile, False);
end;
借助函数 IOTAProject.AddFile(FileName, IsUnitOrForm)
。请注意,我这样称呼它:
if FPersonality = ppCppBuilder then
AddReferenceFiles(InstallProject,
['rtl.bpi', 'designide.bpi', 'vcl.bpi', 'vclactnband.bpi',
'vclx.bpi', 'xmlrtl.bpi'])
else
AddReferenceFiles(InstallProject,
['rtl.dcp', 'designide.dcp', 'vcl.dcp', 'vclactnband.dcp',
'vclx.dcp', 'xmlrtl.dcp']);
请注意文档说:
{ Call this function to add an arbitrary file to the project. NOTE: some
files have special meaning to different projects. For example: adding
VCL60.DCP will cause a new entry in a package project's "requires" list
while it will be a raw file to any other project type. Set IsUnitOrForm
to true for files that are considered items that the project would
process directly or indirectly (ie. .pas, .cpp, .rc, etc..) or can be
opened in the code editor. For all others, including binary files
(.res, .bpi, .dcp, etc..) set this to False. }
procedure AddFile(const AFileName: string; IsUnitOrForm: Boolean);
这意味着如果你添加一个'bla.dcp'
它会自动落在requires
部分,如果你添加一个'bla.pas'
文件它会落在[=17] =] 部分。我花了一段时间才知道。