How to get interface name at runtime?

If I have an object that implements the interface, it is not difficult to use RTTI to find the interface and get its GUID. But if I want his name, is there any way to get this? It's simple enough to get the class name, but for interfaces it seems a little more complicated ...

+3
source share
1 answer

The tricky part is getting the RTTI from the interface. If you succeed, you should already have a name in the entry pointer PTypeInfo.

In one of my programs, I wrote a special registration system that matched GUIDs with strings so that I could report failed calls QueryInterfaceand not make " as". This was in delphi 2005. I understand that in later versions of Delphi RTTI for interfaces has progressed so that I may not need this system.

+1
source

Source: https://habr.com/ru/post/1714430/


All Articles