【问题标题】:How to add a target platform to a Delphi Project via the OpenTools API如何通过 OpenTools API 将目标平台添加到 Delphi 项目
【发布时间】:2014-01-09 14:53:38
【问题描述】:
在 Delphi(XE2 到 XE5)中,如何以编程方式将目标平台添加到项目中?
“以编程方式”是指通过 OpenTools API,而不是 .dproj 文件的转换。这将在 IDE 向导/专家中完成。
我查看了 ToolsAPI 单元,您似乎可以获得活动平台和支持的平台列表,但添加新目标平台并没有什么明显的。
【问题讨论】:
标签:
delphi
delphi-xe2
wizard
toolsapi
【解决方案1】:
这似乎是可能的。您需要查看的单位是PlatformAPI。有你需要的界面是:
{ Provides information on platform-specific information held by a project }
IOTAProjectPlatforms160 = interface(IInterface)
['{E1C62726-BD51-4D4E-A2F2-9A8A59F272AE}']
{ Add an available platform to the project }
procedure AddPlatform(const PlatformName: string);
{ Return the currently active platform key }
function CurrentPlatform: string;
{ Return enabled state of the requested platform }
function GetEnabled(const PlatformName: string): Boolean;
{ Return an array of strings representing the enabled platforms for a project }
function GetEnabledPlatforms: TArray<string>;
{ Return the profile name associated with the specified platform }
function GetProfile(const PlatformName: string): string;
{ Does the project support platform specified by PlatformName? }
function GetSupported(const PlatformName: string): Boolean;
{ Return an array of strings representing the valid platforms for a project }
function GetSupportedPlatforms: TArray<string>;
{ Set a platform as disabled for this project (cannot be made active) }
procedure SetEnabled(const PlatformName: string; Value: Boolean);
{ Set the profile name for the specified platform. Pass an empty string to
clear the profile }
procedure SetProfile(const PlatformName, ProfileName: string);
{ Indicate the specified platform is supported or not }
procedure SetSupported(const PlatformName: string; Value: Boolean);
{ Return whether or not the profile associated with PlatformName is the default profile
for that platform }
function UsingDefaultProfile(const PlatformName: string): Boolean;
property EnabledPlatforms: TArray<string> read GetEnabledPlatforms;
property Enabled[const PlatformName: string]: Boolean read GetEnabled write SetEnabled;
property Profile[const PlatformName: string]: string read GetProfile write SetProfile;
property Supported[const PlatformName: string]: Boolean read GetSupported write SetSupported;
property SupportedPlatforms: TArray<string> read GetSupportedPlatforms;
end;
AddPlatform 方法似乎是你的人选。
请注意,我没有尝试调用该方法。事实上,我所做的只是在工具 API 源文件夹中搜索词 platform。