小编Jan*_*sen的帖子

如何在 Delphi 调试器可视化工具中拦截函数返回值?

我有一个工作调试器可视化工具,可以帮助可视化 TIntTime 类型的变量。

TIntTime = 整数类型;

可视化工具用时间字符串 HH:MM:SS 替换自午夜以来的秒数。在调试会话期间,这对于 TIntTime 类型的变量效果很好,但对于函数则不然。例如,如果我将 GetiTime 放入手表中

function GetiTime: TIntTime;
begin
  Result:=30000;
end;
Run Code Online (Sandbox Code Playgroud)

手表将显示 30000。预期替换值为“08:20:00”。可视化工具不会拦截 TIntTime 类型的函数返回值,这就是问题所在。

我正在使用 Delphi 10 西雅图。我的可视化工具基于 Delphi 10\source\Visualizers 中的 DateTimeVisualizer.pas。DateTimeVisualizer 建议通过在 GetSupportedType 中使用类型名称字符串“function: TIntTime”来拦截函数返回值。我努力了

'function: TIntTime'
'function:TIntTime'
'function::TIntTime'
Run Code Online (Sandbox Code Playgroud)

没有运气。我怀疑这是一个使该类型名称字符串正确的问题,但无法在互联网上找到有关格式的信息。

如果我将 GetDateTime 放入手表中,它会按预期显示“14-02-2018 13:20:30”。如果我在选项中关闭 TDateTime/TDate/TTime 可视化工具,手表会显示 43145.5559... 这告诉我可以使用可视化工具拦截函数返回值。

  function GetDateTime: TDateTime;
  begin
    Result:=EncodeDateTime(2018,2,14,13,20,30,0);
  end;
Run Code Online (Sandbox Code Playgroud)

就我而言,不能选择使用 TDateTime 数据类型。所以我的问题是:如何让可视化工具拦截 TIntTime 类型的函数返回值?

以下是 TIntTime 可视化工具的来源

unit IntTimeVisualizer;

interface

procedure Register;

implementation

uses
  Classes, Forms, SysUtils, ToolsAPI;

resourcestring
  sIntTimeVisualizerName = 'TIntTime Visualizer for Delphi'; …
Run Code Online (Sandbox Code Playgroud)

delphi debuggervisualizer

5
推荐指数
0
解决办法
376
查看次数

标签 统计

debuggervisualizer ×1

delphi ×1