pascalabcnet/bin/Lib/__RunMode.pas
Mikhalkovich Stanislav 02da0ee365 bug fix #2205
CommandLineArgs сделаны функцией,
IndicesOf возвращает теперь sequence of integer
убраны некоторые лишние инициализации модуля PABCSystem
2020-02-23 02:00:43 +03:00

66 lines
2 KiB
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
///--
unit __RunMode;
//------------------------------------------------------------------------------
// Модуль, подключаемый в режиме запуска без связи с оболочкой
// (с) DarkStar 2007
// Функции:
// 1. Перехват исключений по AppDomain.CurrentDomain.UnhandledException и
// вывод их в консоль
// 2. Если это - консольное окно, то устанавливает имя заголовка на имя exe-файла
//------------------------------------------------------------------------------
interface
///--
procedure __InitModule__;
implementation
uses PABCSystem, System;
procedure DbgExceptionHandler(sender: object; args: UnhandledExceptionEventArgs);
begin
var e := Exception(args.ExceptionObject);
if args.IsTerminating and (ExecuteBeforeProcessTerminateIn__Mode<>nil) then
ExecuteBeforeProcessTerminateIn__Mode(e);
if IsConsoleApplication then begin
Console.Error.Write('Unhandled Exception: ' + e.ToString);
if args.IsTerminating then
Halt;
end else
raise e;
end;
var __initialized := false;
procedure __InitModule;
begin
if (CommandLineArgs.Length>0) and (CommandLineArgs[0]='[RUNMODE]') and not ExecuteAssemlyIsDll then begin
AppDomain.CurrentDomain.UnhandledException += DbgExceptionHandler;
if IsConsoleApplication then
Console.Title := ExtractFileName(GetEXEFileName);
var _a := new string[_CommandLineArgs.Length-1];
for var i:=1 to _CommandLineArgs.Length-1 do
_a[i-1] := _CommandLineArgs[i];
_CommandLineArgs := _a;
end;
end;
procedure __InitModule__;
begin
if not __initialized then
begin
__initialized := true;
__InitPABCSystem;
__InitModule;
end;
end;
begin
__InitModule;
end.