CORBA interface and Variants lazarus / 62-General ---------------------------------------------------------------------- JdeHaan · 2024-04-16 10:51 Hi, For various reasons I use CORBA interfaces. In my code I also use Variants, to support different types of value in a variable. This may include an interface value. At some point I need to check if a Variable (of type Variant) is a (CORBA) interface. I use the following code for that: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i isSymTabEntry := VarSupports(Value, StringToGUID(ISymTabEntry_GUID), SymTabEntry); Here, Value is a variable of type Variant, ISymTabEntry_GUID, is a string constant, such as: '{DCD95BA9-90CB-9AA2-0090-DBA0749AF179}' and SymTabEntry is a CORBA interface ISymTabEntry, defined as : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   ISymTabEntry = interface    [ISymTabEntry_GUID]    function getName: String;    //etc…  end; It doesn’t seem to work. Function getName produces the GUID string constant instead of the name of the SymTabEntry… Could it be that only COM interfaces can be used with VarSupports? Is there maybe another way of retrieving an Interface value/variable from a Variant value? Any suggestion is appreciated. Regards, J ------------------------------ I use trunk Lazarus and FPC on MacOS Sonoma ---------------------------------------------------------------------- cdbc · 2024-04-16 12:17 Hi Have you tried:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i S:= SymTabEntry.GetName(); // NOTE the () Funny thing about corba-interfaces: *they typecast to string* i.e.: the string representation of the guid. So given your method returns a string, if you don't add the parantheses / braces, it doesn't count that as a method-call and returns the string-rep. of the interface... At least that's my experience so far... Regards Benny ---------------------------------------------------------------------- marcov · 2024-04-16 13:11 Afaik the methods to query nearly everything from an interface are in iunknown (the com base interface). So yeah, probably that won't work. ---------------------------------------------------------------------- JdeHaan · 2024-04-16 14:06 Ok, thanks. @cdbc, I tried but unfortunately I get the same result... Edit: Just found out that the VarSupports never returns TRUE, so this is not working ---------------------------------------------------------------------- Thaddy · 2024-04-16 14:27 Quote from: JdeHaan on April 16, 2024, 12:51:37 pmFor various reasons I use CORBA interfaces. Bad habit. Give me one various reason. Then I might be able to help. ---------------------------------------------------------------------- JdeHaan · 2024-04-16 14:56 I know it's not optimal to use Corba interfaces. But, the problem I was facing was that in order to use a COM interface, my class definition had to inherit from TInterfacedObject, but I also had to inherit from another class. To prevent that I used Corba. I'm now thinking of creating my own value type, based on a variant record instead of a Variant type. So, basically: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type   TMyRec = record    case byte of     0: (IntVal: Integer);     1: (FloatVal: Real);     2: (IntfVal: IMyCorbaInterface);  end; ---------------------------------------------------------------------- PascalDragon · 2024-04-16 18:35 Quote from: JdeHaan on April 16, 2024, 04:56:48 pmBut, the problem I was facing was that in order to use a COM interface, my class definition had to inherit from TInterfacedObject, but I also had to inherit from another class. To prevent that I used Corba. You don't have to inherit from TInterfacedObject, but what you have to do is to implement the methods of IInterface/IUnknown (which is what TInterfacedObject does).