LoginSignup
12
3

Delphi で生成された EXE が動作する Windows のバージョン

Last updated at Posted at 2021-09-11

はじめに

Delphi で生成された EXE が動作する Windows のバージョンを調べてみました。

image.png

調査には Delphi 付属の TDUMP.EXE を使用しています。

See also:

Delphi で生成された EXE が動作する Windows のバージョン

調査結果です。

バージョン O/S Version Subsystem Version
Delphi (16bit) 3.1
Delphi 2 1.0 4.0
Delphi 3 1.0 4.0
Delphi 4 1.0 4.0
Delphi 5 1.0 4.0
Delphi 6 4.0 4.0
Delphi 7 4.0 4.0
Delphi 2005 4.0 4.0
Delphi 2006 4.0 4.0
Delphi 2007 4.0 4.0
Delphi 2009 5.0 5.0
Delphi 2010 5.0 5.0
Delphi XE 5.0 5.0
Delphi XE2 5.0 5.0
Delphi XE3 5.0 5.0
Delphi XE4 5.0 5.0
Delphi XE5 5.0 5.0
Delphi XE6 5.0 5.0
Delphi XE7 5.0 5.0
Delphi XE8 5.0 5.0
Delphi 10 Seattle 5.0 5.0
Delphi 10.1 Berlin 5.0 5.0
Delphi 10.2 Tokyo 5.0 5.0
Delphi 10.3 Rio 5.0 5.0
Delphi 10.4 Sydney 5.0 5.0
Delphi 11 Alexandria 6.0 6.0
Delphi 12 Athens 6.0 6.0

PE ヘッダーからみたマイルストーンは

  • Delphi - Windows 3.1 で動作
  • Delphi 5 - Win32s でも動作するかもしれない最終版
  • Delphi 2007 - Win9x 系で動作するかもしれない最終版
  • Delphi 10.4 Sydney - Windows 2000 / XP で動作するかもしれない最終版

のようです。

See also:

ターゲットプラットフォームとしての Windows をサポートする Delphi のバージョン

ターゲット Windows のバージョンと Delphi の関係です。言い換えれば、Delphi でコンパイルしたプログラムの動作が保証されている Windows のバージョンです。

Windows サポート開始 サポート終了
Windows 11 Delphi 11.0 Alexandria
Windows 10 Delphi XE8
Windows 8 / 8.1 Delphi XE3
Windows 7 Delphi 2010
Windows Vista Delphi 2007 Delphi XE6
Windows XP Delphi 7 Delphi XE2
Windows 2000 Delphi 6 Delphi 2009
Windows Me Delphi 6 Delphi 6 1
Windows 98 / 98 SE Delphi 4 Delphi 7
Windows NT 4.0 Delphi 3 Delphi 6
Windows 95 Delphi 2 Delphi 5
Windows NT 3.51 Delphi 2 Delphi 3
Windows 3.1 Delphi 1 Delphi 1 2

公式のドキュメントも途中までは "開発プラットフォーム (IDE の動作環境) =ターゲットプラットフォーム" だったため、独自調べです。ターゲットプラットフォームが明示されるようになったのは 10.1 Berlin 以降です。

See also:

おわりに

Delphi 11 Alexandria でコンパイルしたプログラムを Windows XP で動作させようとするとエラーになります。

image.png

11.0 Alexandria 以降で吐かれた EXE は基本的に Windows XP 以前で動作しません。

・PE ヘッダーフラグの変更

PE ヘッダーフラグを変更すれば Windows XP で動作しない事もありません。

image.png

以前作った**「メモ帳クローン」**のプロジェクトファイルを 11.0 Alexandria で開き、PE ヘッダフラグを 5.0 に設定してビルドしてみましたが、一通り普通に動作しました 3

notepad_clone.dpr
program notepad_clone;

{$SETPEOSVERSION 5.0}     // 5.0 に変更
{$SETPESUBSYSVERSION 5.0} // 5.0 に変更

uses
  Vcl.Forms,
  frmuMain in 'frmuMain.pas' {Form1},
  frmuGotoLine in 'frmuGotoLine.pas' {Form2},
  frmuHeaderFooter in 'frmuHeaderFooter.pas' {Form3},
  Vcl.Themes,
  Vcl.Styles;

{$R *.res}

begin
  ReportMemoryLeaksOnShutdown := True;
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.Title := 'メモ帳クローン';
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

プロジェクトオプションのリンカオプションを変更しても同じ効果が得られます。

image.png

GetTickCount64 対策

TThreadPool を使っていると変な動作になるかもしれません。内部で TThread.GetTickCount64 が使われており、このせいで XP では外部例外が発生します。

image.png

TThread.GetTickCount64 そのものは Delphi 11 Alexandria で実装されたため、過去のバージョンのコードでスレッドが使われていても多くの場合で問題になる事はないと思われますが、System.Threading.TThreadPool では内部で TThread.GetTickCount64 が使われるようになっています。

この問題を回避するには $(BDS)\source\rtl\common にある System.Threading.pas を改変して使うといいようです。

System.Classes.TMultiWaitEventImpl にもクラスメソッドとして GetTickCount64 があるのですが、こちらは Delphi 11 Alexandria になって実装されているため (過去のバージョンでは GetTickCount が実装されている)、問題になる事はまずないと思います。

XP で動作するバイナリは 10.4 Sydney 以前で作るのが無難かと思います。

この件は 11.0 Alexandria Patch 1 において修正されました。

See also:

  1. Delphi 7 が Windows Me に対応していないのは単なる記載漏れのような気も。

  2. Delphi 2 ~ 4 の CD-ROM には Delphi 1 のインストーラが含まれています。

  3. アイコンがちゃんと 11.0 Alexandria のものになっています。

12
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
3