2013-04-16 61 views
0

我想恢复和编译XE2下的一些旧的来源。什么替代ToolServices.GetUnitCount?

有一个例程使用在ToolTemplate中定义的'ToolServices.GetUnitCount'(它被废弃了):TIToolServices = nil;

而且,TIToolServices在ToolIntf.pas(也建议使用)作为TIToolServices =类(TInterface)定义

最后,GetUnitCount被描述为“返回属于该项目单位的当前数目” 。

问题是这样的:我怎样才能(不使用ExptIntf.pas或ToolIntf.pas)获得属于该项目的单位的当前数量?

回答

0

在XE2和XE3帮助文件中有关于'Extending the API'的文档,它提供了有关使用模块和文件以及使用编辑器资源的信息。 'EditorViewAPI'的演示可能对您有所帮助。所有的服务都可以通过ToolsAPI和IOTAServices接口获得。与早期版本相比,文档和样本数量要多得多。 EditorViewAPI是一个实际安装的示例应用程序,您可以尝试以查看事情的工作方式。

1

适当的反应取决于你的代码做什么,但良好的候选人可能是:

  • IOTAProject40

    { Return the number of owned modules } 
    function GetModuleCount: Integer; 
    { Return the Indexed owned Module Info } 
    function GetModule(Index: Integer): IOTAModuleInfo; 
    { Return the Project options } 
    
  • IOTAProject140

    { Returns a list of fully qualified file names. This will contain files 
        that do not show up in the project manager, for example, the project's 
        .res file } 
    procedure GetCompleteFileList(FileList: TStrings); 
    

这两个都是IOTAProject界面的祖先,所以你有两种口味。要使用Open Tools API,您必须使用ToolsAPI单元。看看你的Delphi安装的source\ToolsAPI文件夹。