
How to detect OS theme modes on all platforms using Delphi | By Alessandro | January 2025

Here, I provide a complete complete delphi unit to include in your Fmx projects in case you want to detect the Light And Dark Operating system theme modes. This is useful when targeting multiplatform devices, and it works for MacOS, Android, iOS and Windows.
We use the Fmx.platform Library for MacOS, Android and iOS using the TPLATFormServices We can extract the current theme.
Now, for Windows, we have to cross the register to obtain the selected user mode: clear or dark. On this basis, we will return the Tsystemhemekind in order To keep the use of data types on all platforms consistent.
This solution is a wrapper against independent platforms to make sure you can easily distinguish the Light And Dark Modes, as one of my users really wanted to have a Dark Mode version too!