高手请进,如何直接得到过程或函数的地址,不用ExceptionAddr (50分)

  • 主题发起人 主题发起人 yyanghhong
  • 开始时间 开始时间
Y

yyanghhong

Unregistered / Unconfirmed
GUEST, unregistred user!
我在作一个通用日志程序,我想实现的功能是<br>this is a procedure<br>procedure loaddb;<br>begin<br>write_log('process is started');<br>end;<br><br>在write_log中, 我想得到这个过程所在的程序名,单元名,过程名。<br>我知道, 如果用Raise Exception, 我可通过ExceptionAddr得到过程的地址,然后查程序的map文件,<br>可得到这个过程所在的程序名,单元名,过程名.<br>但我直接得到这个过程的地址。不用Raise Exception。<br>详见http://delphi.mychangshu.com/dispdoc.asp?id=238<br>
 
any suggestion is welcome
 
代码:
<br>procedure Hello<br>begin<br>&nbsp; ShowMessage(Format('The address of procedure is %p', [@Hello]))<br>end;
 
to Qiuliang<br>thanks, this answer is quite close, but it is not what i want, you know, i'd like to write a class that is provided<br>to other developer, so i want to get the name of unit and procedure through the<br>function instead of typing directly, it can exclude the possibility of typing error of developer<br>I also would give you some score.
 
接受答案了.
 
后退
顶部