[fpc-pascal] Question about interfaces and patch

Thomas Schatzl tom_at_work at gmx.at
Fri Mar 25 15:35:39 CET 2005


ml schrieb:
> I made one wrong statement.
> It's not "as" that doesn't work. getinterfaceentry works only for
> interfaces that have guid specified. By default guid is zeroed, and
> getinterfaceentry just returns first interface in table, which means
> wrong. Same problem shows in Support too.

Hmmm, Delphi gives a compile time error if "as" is used on an interface 
without GUID, same for support()... since both use the interfaces IID to 
query for existence of an interface (either directly or via 
QueryInterface of IUnknown).

> Any better suggested approach? (Second possible solution would be
> implementing some other checking that's invoked if guid is 0) I am not
> familiar with what guid would be (I suspect that it has some higher
> meaning in windows, because all windows interfaces are specified with
> guid, now even m$ stopped using specified guid in .net), so I would

The GUID (=UUID) uniquely identifies a COM interface. A .net interface 
is not a COM interface, it's more a language construct like in Java.
By some wrapping any(?) .net interface can be used as COM interface 
afaik (and the other way round) though.
.net provides more advanced means of querying run-time type information 
than the ones available in Object Pascal, e.g. it likely does not need 
to rely on a GUID for these types of operation, so there's no need to 
specify this by default.

Btw, to implement unnamed properties of (non-COM) interfaces (as the one 
available in objfpc mode) there's imo need for more sophisticated rtti; 
e.g. so that this would work, you'd need a way to query the read and 
write methods of the particular class of the instance and call them.
Neither querying of properties nor getting info on the read/write 
methods of properties is possible atm since Object Pascal does not store 
this info anywhere by default afaik (for all visibility types of 
properties, for all Pascal objects).
[Maybe I'm wrong, I'm not so into rtti]

> appreciate some help by suggesting. And yes, this is a bug not a
> feature.

Either automatically create a good GUID for the interface (there should 
be a CreateGUID() method in fpc), or error out like Delphi (to be


More information about the fpc-pascal mailing list