【问题标题】:What replaces ToolServices.GetUnitCount?什么替代了 ToolServices.GetUnitCount?
【发布时间】:2013-04-16 02:56:58
【问题描述】:

我正在尝试在 XE2 下恢复和编译一些旧的源代码。

有一个例程使用在 ExptIntf.pas(已弃用)中定义的“ToolServices.GetUnitCount”作为 ToolServices:TIToolServices = nil;

而且,TIToolServices 在 ToolIntf.pas(也已弃用)中定义为 TIToolServices = class(TInterface)

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

问题是:我如何(不使用 ExptIntf.pas 或 ToolIntf.pas)获得属于该项目的当前单元数?

【问题讨论】:

    标签: delphi delphi-xe2 delphi-xe


    【解决方案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 文件夹。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2013-07-16
        • 1970-01-01
        • 1970-01-01
        • 2010-09-25
        • 2012-05-07
        • 2015-10-13
        • 2020-01-31
        • 2010-10-04
        • 2010-10-26
        相关资源
        最近更新 更多