Einzelnen Beitrag anzeigen

haui95

Registriert seit: 1. Feb 2012
Ort: Niedersachsen
29 Beiträge
 
Delphi 7 Personal
 
#7

AW: EOSError, Code 1400, Ungültiges Fensterhandle - Kosole

  Alt 17. Jun 2012, 14:43
Habe es nun noch einmal probiert mit einem Result := False; als Initialisierung. Jedoch kommt nun wieder eine Excption EOSError.
Lasse ich die Initialisierung weg, läuft das Programm und ich kann die Konsole ohne Fehler und Exceptions schließen.

Delphi-Quellcode:
program Project1;

uses
  Windows, SysUtils, Classes, XPMan;

{$APPTYPE CONSOLE}

{$R *.RES}

procedure ShowSplashForm; stdcall; external 'splash.dll';

function ConsoleEventProcedure(CtrlType: DWord): Bool; stdcall;
begin
  Result := False; // <-- Löst Exception aus !?
  if (CtrlType = CTRL_CLOSE_EVENT) then
    begin
      exit;
    end;
  Result := True;
end;

begin
  SetConsoleCtrlHandler(@ConsoleEventProcedure, True);
  try
    ShowSplashForm;
  except
    exit;
  end;
end.
Delphi-Quellcode:
program Project1;

uses
  Windows, SysUtils, Classes, XPMan;

{$APPTYPE CONSOLE}

{$R *.RES}

procedure ShowSplashForm; stdcall; external 'splash.dll';

function ConsoleEventProcedure(CtrlType: DWord): Bool; stdcall;
begin
  Result := False;
  if (CtrlType = CTRL_CLOSE_EVENT) then
    begin
      exit;
      Result := True; // <-- so geht's ! :D
    end;
end;

begin
  SetConsoleCtrlHandler(@ConsoleEventProcedure, True);
  try
    ShowSplashForm;
  except
    exit;
  end;
end.

MfG
Hauke

Geändert von haui95 (17. Jun 2012 um 14:55 Uhr)
  Mit Zitat antworten Zitat