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

28
uses
  TypInfo;

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

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