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.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
rhody
  • 2,274
  • 2
  • 22
  • 40

2 Answers2

29
uses
  TypInfo;

Guid := GetTypeData(TypeInfo(IPluginAPI))^.Guid;
Ondrej Kelle
  • 36,941
  • 2
  • 65
  • 128
0

As mentioned by RRUZ in comment to older reply:

uses
  System.Rtti;

//...
var Guid := TRttiInterfaceType(TRttiContext.Create.GetType(TypeInfo(IPluginAPI))).GUID;
George Birbilis
  • 2,782
  • 2
  • 33
  • 35