The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘Undocumented Delphi’ Category

Exceptions and DLL in Delphi – Stack Overflow

Posted by jpluimers on 2025/05/20

Every once in a while I discover an answer I have not yet put on my blog, especially as related answer are always interesting.

This is one that didn’t make it until now: [Wayback/Archive] Exceptions and DLL in Delphi – Stack Overflow (thanks [Wayback/Archive] jpfollenius, [Wayback/Archive] Deltics and [Wayback/Archive] Lars Truijens)

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi, Windows Development | Leave a Comment »

Where can I find a comprehensive list of Delphi “compiler magic” declarations? – Stack Overflow

Posted by jpluimers on 2022/11/16

A long time ago, I posted one of the answers to [Wayback/Archive] Where can I find a comprehensive list of Delphi “compiler magic” declarations? – Stack Overflow

So for my link archive, these are the main ways of assembling an (always incomplete, as only partially documented) list:

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, EKON, Event, Software Development, Undocumented Delphi | Leave a Comment »

On TStrings (and TStringList) sorting: what the default Sort behaviour is and how to change sorting order

Posted by jpluimers on 2021/12/07

Because I need this eventually, here the full quote of my answer in [Wayback] sorting – How can I get TStringList to sort differently in Delphi – Stack Overflow (The default Sort behaviour is to accommodate i18n sorting in natural order):

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi | Leave a Comment »

Parser generator toolset for Delphi (Yacc & Lex)

Posted by jpluimers on 2021/08/03

The most current Lex and Yacc for Delphi is [WayBack] GitHub – RomanYankovsky/ndyacclex: Parser generator toolset for Delphi (Yacc & Lex).

It came up during a funny Twitter thread, where one of the Delphi team members asked for it, despite – after decades of asking – there still being no official Delphi grammar available from the Delphi team, nor Google Search skills [WayBack].

Basically a parser generator is only as useful as the grammar you have for it.

There is no open source grammar for Delphi yet, so the best you can start with is from the same author: [WayBack] GitHub – RomanYankovsky/DelphiAST: Abstract syntax tree builder for Delphi

With DelphiAST you can take real Delphi code and get an abstract syntax tree. One unit at time and without a symbol table though.

Relevant tweets:

–jeroen

Posted in Delphi, Development, Software Development, Undocumented Delphi | 1 Comment »

file – String format procedure similar to writeln – Stack Overflow

Posted by jpluimers on 2021/05/11

Cool Format feature from [WayBack] file – String format procedure similar to writeln – Stack Overflow:

The cool thing about using Format is that you use for Format Strings not only to parameterize things like width and precision inside that Format String, but also as parameters like you normally would provide values.

You can get very close to using a width of 8 and a precision of 2, like the example in your question.

For instance, to quote the documentation:

Format ('%*.*f', [8, 2, 123.456]);

is equivalent to:

Format ('%8.2f', [123.456]);

That is a much overlooked feature of Format and Format Strings.

Edit 20250910:

This was part of my answer¹ there to mimic WriteLn formatting behaviour which was not even documented at the now deleted [Wayback/Archive] Standard Routines and I/O.

Normally deleted information like above results in worse information at their current documentation site.

This time however was an exception: the current documentation is better².

¹ the start of my answer:

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi | Leave a Comment »

Delphi: got “EOleException with message ‘Microsoft MSXML is not installed'” in a console or test project?

Posted by jpluimers on 2021/03/31

Did you ever get this run-time error in a console or test project?

EOleException with message 'Microsoft MSXML is not installed'

It means that CoInitialize or CoInitializeEx needs to be called in the thread that uses MSXML.

Then an easy workaround is to:

  1. use the unit System.Win.ComObj in any unit that (indirectly) uses Xml.XMLDoc (for instance any unit using an XML Data Binding generated unit),
  2. use the unit System.SysUtils as well (because it defines TProcedure used below)
  3. add this code in in your initialization section (which is what VCL TApplication.Initialize does):

if InitProc <> nil then TProcedure(InitProc); // Calls CoInitialize for the main thread and prevents "EOleException with message 'Microsoft MSXML is not installed'"

The initialization section of System.Win.ComObj sets up InitProc to cals CoInitialize for the main thread, which usually suffices for these simple VCL projects, but not for most console or test projects.

Based on ideas I got after reading [WayBack] 为什么LoadXMLDocument在线程类中使用会报错?-CSDN论坛 (for which Google Translate actually does a goot job [Archive.is])

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi | Leave a Comment »

When your Delphi IDE suddenly skips unsaved changes during compilation(TL;DR: watch early signs your IDE is hosed, then restart without saving)

Posted by jpluimers on 2021/03/24

A while ago, I observed that when compiling, my Delphi IDE would not take into account unsaved changes any more.

This ws in a time when I was tracking down some hard to reproduce problems of code that sometimes would and sometimes would not compile at all.

The solution was this:

[HKEY_CURRENT_USER\Software\Embarcadero\BDS\18.0\Compiling]
"BackgroundCompilation"="False"

Somehow, the Delphi IDE had turned this flag to True without me telling it did, nor me changing an option (heck if you do a “Delphi” “BackgroundCompilation” – Google Search you hardly get any meaningful results).

Luckily, I did remember what happened around the bahaviour change: the compiler had encountered a strange error, and the IDE had become unstable.

With an unstable IDE, I did have seen damage in saved source files in the past, so I always use version control with Delphi as that allows easier to spot file differences.

What I did not anticipate was that it could corrupting my persisted IDE settings, though every now and then.

Detecting early signs of the IDE becoming unstable

  • any internal compiler error (AV or not)
  • refactoring not succeeding while it should
  • insert mode suddenly becomes override or vice versa
  • editor block selection is suddenly turned on
  • any access violation or pointer error exception

Sometimes (but not always) these can be early signs too

  • debugger blue dots not matching compiled code lines
  • the debugger not being able to debug code despite blue dots being there
  • properties in the object inspector having changed without manual action

Be prepared for an unstable IDE

  • Save your work often
  • At the earliest sign of an unstable IDE: kill (do not save work!) the affected bds.32 process using Process Explorer

BackgroundCompilation

A “Delphi” “BackgroundCompilation” – Google Search did not get much relevant results. Below are the most relevant ones I could find from it:

Too bad Google does not index the WayBack machine, as I think it contains relevant material that is now hard to find.

So it looks like the feature was introduced somewhere close to Delphi 5:

[HKEY_CURRENT_USER\Software\Borland\Delphi\5.0\Compiling]
"Show Compiler Progress"="True"
"Warn on Package Rebuild"="-1"
"Compile Beep"="0"
"Cache Headers"="0"
"BackgroundCompilation"="0"

“Delphi” “Background Compilation” – Google Search shows much more information, based on what it returned I found that the first actual documentation was for Background Compilation in Delphi 2010, some 10 years after it became available:

The image in the blog post of former product manager Andreano Lanusse shows why I did not see the behaviour: when background compiling is active, the progress dialog is transparent (and non-modal). I did not have the compiler progress enabled, so never saw that dialog change behaviour.

–jeroen

 

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi | Leave a Comment »

Delphi object instance lifetime demo; do not use AfterConstruction as a poor-mans way to work around non-virtual constructor or undetermined Create hierarchy calls

Posted by jpluimers on 2021/03/23

I think using AfterConstruction is a poor man’s solution that you should only use in exceptional cases, as it is:

  • called only after the last constructor in the chain is called.
  • called outside of the constructor chain (i.e. exceptions in it will not automatically call the destructor chain, nor BeforeDestruction)
  • meant to add any initialization code that requires a fully created object instance.

There were quite a few customer sites I visited that were using AfterConstruction. Usage roughly falls into two cases:

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi | 1 Comment »

Delphi use of FS segment: structured exception handling

Posted by jpluimers on 2021/03/16

A while ago, I had to trace through a lot of code in the CPU pane to track down some memory allocation related issues.

I wondered what the use of the FS segment was about, so via [Archive.is] delphi what is fs segment used for – Google Search, I found that it is related to Win32 Structured Exception handling and therefore not limited to Delphi, through these links:

A few disassembly parts to show how the Delphi Win32 compiler uses this for try finally blocks and try except blocks is below. Note that often, there are implicit try finally blocks when having managed method parameters or local variables.

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, Software Development, Undocumented Delphi, Windows Development | Leave a Comment »

Short Delphi tip: ensuring RTTI for classes is included

Posted by jpluimers on 2021/03/04

When using RTTI in Delphi, you really want the RTTI to be available.

The compiler includes RTTI for classes, as soon as it found that a class is touched by code that will be executed.

So in order to include RTTI for classes into the executable, you have to ensure you touch the class.

Basically there are two tricks for that.

  1. A small one step process which incurs a tiny bit of string overhead:
    class function TObject.ClassName: string;
    begin
      Result := UTF8ToString(_PShortStr(PPointer(PByte(Self) + vmtClassName)^)^);
    end;
    • Touch the [WayBack] ClassName class function for each class, for instance in an initialization section or registration method, like this:
      TMyClass.ClassName;
      TMyOtherClass.ClassName;
  2. A small two step process
    1. Create a method like this: procedure EnsureRttiIsAvailable(const Classes: array of TClass); begin end;
    2. Pass the classes to it like this:
      EnsureRttiIsAvailable([TMyClass, TMyOtherClass]);

I like the second solution more, as it clearly states the intent.

The first trick is calling a function without using the result. This is a Pascal construct that looks odd, but is perfectly valid to use: basically you discard the result.

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi | Leave a Comment »