如何在 Delphi 7 中获取当前方法的名称? [英] How to get current method's name in Delphi 7?
本文介绍了如何在 Delphi 7 中获取当前方法的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法可以知道我当前使用的方法的名称吗?
Is there any way to know the name of a method I'm currently in?
所以:
procedure TMyObject.SomeMethod();
begin
Writeln('my name is: ' + <hocus pocus>);
end;
会产生这样的输出:
我的名字是:SomeMethod
推荐答案
JCL 是免费的并且有功能.这确实取决于可以进行堆栈跟踪的程度以及存在多少调试信息.
JCL is free and has functions for that. It does depend on how well a stack trace can be made and how much debug information is present.
JclDebug.pas
JclDebug.pas
function FileByLevel(const Level: Integer = 0): string;
function ModuleByLevel(const Level: Integer = 0): string;
function ProcByLevel(const Level: Integer = 0): string;
function LineByLevel(const Level: Integer = 0): Integer;
这篇关于如何在 Delphi 7 中获取当前方法的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文