15

If I have an interface such as:

IPluginAPI = interface
['{590DFF0B-CA00-46CC-84B0-3848103D4C5A}']
   function add (a : double; b : double) : double;
   function sub (a : double; b : double) : double;
   function mult (a : double; b : double) : double;
   function divide (a : double; b : double) : double;
end;

Is there anyway to get the value of the GUID using RTTI? I am using Delphi XE.

2 Answers 2

29
uses
  TypInfo;

Guid := GetTypeData(TypeInfo(IPluginAPI))^.Guid;
3
  • 5
    +1 Too bad the documentation is so far out of date....... Dec 8, 2011 at 23:51
  • 1
    Wow, that page is outright misleading. Note to self: Always see the source. Dec 8, 2011 at 23:58
  • 11
    +1, another option using the new Rtti TRttiInterfaceType(TRttiContext.Create.GetType(TypeInfo(IPluginAPI))).GUID
    – RRUZ
    Dec 9, 2011 at 0:06
0

As mentioned by RRUZ in comment to older reply:

uses
  System.Rtti;

//...
var Guid := TRttiInterfaceType(TRttiContext.Create.GetType(TypeInfo(IPluginAPI))).GUID;
1

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.