Recent

Author Topic: Typelibrary in my own library?  (Read 344 times)

cdbc

  • Hero Member
  • *****
  • Posts: 2816
    • http://www.cdbc.dk
Typelibrary in my own library?
« on: May 15, 2026, 11:22:02 am »
Hi
Is it possible to include a 'type-library' in one of my own libraries, so that users can use 'importtl' to get the types etc. from the library, like e.g. we can from Microsoft's COM-services?!?
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Thaddy

  • Hero Member
  • *****
  • Posts: 19268
  • Glad to be alive.
Re: Typelibrary in my own library?
« Reply #1 on: May 15, 2026, 11:31:00 am »
I use the type library editor from Delphi 7 for that. I am not aware we have something like that already.
The current CE version of Delphi (12.1) also can do that: New|ActiveX|Type library.
These can be linked in Freepascal as a resource or distributed as a separate tlb file.
Fully compatible.
I have no real preference for the D7 one. It is just that back in the D7 days I used it a lot and it stuck.
« Last Edit: May 15, 2026, 11:34:34 am by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

cdbc

  • Hero Member
  • *****
  • Posts: 2816
    • http://www.cdbc.dk
Re: Typelibrary in my own library?
« Reply #2 on: May 15, 2026, 11:38:58 am »
Hi Thaddy
Yes, ofc. that'll work on winders...
Hmmm, would the format of such a TLB file, happen to be available -- somewhere -- that you know of?
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Thaddy

  • Hero Member
  • *****
  • Posts: 19268
  • Glad to be alive.
Re: Typelibrary in my own library?
« Reply #3 on: May 15, 2026, 12:00:48 pm »
It is only useful on Windows, although maybe for interfaces only it will work. Yes, the format is documented. The code is - of course - in the sources of the importtl utility that comes with fpc.
There are two formats, an idl or ridl file, which is sourcecode like, and the tlb which is the compiled type library resource.
« Last Edit: May 15, 2026, 12:02:53 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

cdbc

  • Hero Member
  • *****
  • Posts: 2816
    • http://www.cdbc.dk
Re: Typelibrary in my own library?
« Reply #4 on: May 15, 2026, 12:23:44 pm »
Thanks mate, was just wondering if there was a cleverer way, than my include files...  ;D
X-platform -- it seems not...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12901
  • FPC developer.
Re: Typelibrary in my own library?
« Reply #5 on: May 15, 2026, 12:45:50 pm »
The code is - of course - in the sources of the importtl utility that comes with fpc.

Afaik it uses COM typelib interfaces to query the library, so it might not know the binary TLB format.

Thaddy

  • Hero Member
  • *****
  • Posts: 19268
  • Glad to be alive.
Re: Typelibrary in my own library?
« Reply #6 on: May 15, 2026, 12:58:27 pm »
Yes, you are right: of course it uses the COM provided infrastructure from stdole2.
That makes it harder to use it on anything thar is not Windows.
Maybe it can be done with extended rtti, though. I mean exposing/reading the interfaces and their methods.
IInvokable, which is simply IInterface compiled in {$M+} state, so with rtti info attached.
« Last Edit: May 15, 2026, 01:12:08 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12901
  • FPC developer.
Re: Typelibrary in my own library?
« Reply #7 on: May 15, 2026, 01:26:31 pm »
I searched for binary TLB tools, and I found this:

https://github.com/dewhisna/TLBTools/tree/master


gidesa

  • Sr. Member
  • ****
  • Posts: 252
Re: Typelibrary in my own library?
« Reply #8 on: May 15, 2026, 04:46:42 pm »
But seems to me that the author cdbc wants to write and deploy his own TLB file.
This is surely possible with Delphi wizard, but I don't know if it's possible with Fpc/Lazarus.
One could be manually write a IDL text file, and compile to TLB with some MS utility (what?).
But writing manually a complex IDL is not so simple, the Delphi wizard do a great work on it.
And, always if I well understand, the target is not Win, but another (Linux, MacOS,..?). So Win
tools are not the solutions.

cdbc

  • Hero Member
  • *****
  • Posts: 2816
    • http://www.cdbc.dk
Re: Typelibrary in my own library?
« Reply #9 on: May 15, 2026, 06:30:13 pm »
Hi
Quote
So Win
tools are not the solutions.
That's right, I'll stay with my include-files...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Thaddy

  • Hero Member
  • *****
  • Posts: 19268
  • Glad to be alive.
Re: Typelibrary in my own library?
« Reply #10 on: May 16, 2026, 10:07:04 am »
Note that interfaces based on IUnknown are cross-platform, but dispatch interfaces are NOT.
Most what you write seems IInterface/IUnknown derived. These not really need a typelib, they only need the GUID constant for the interface querying and documentation.
« Last Edit: May 16, 2026, 10:08:37 am by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

 

TinyPortal © 2005-2018