Win95 vs NT: SetConsoleCtrlHandler()

Hello all,

I have written a console app in D2, and have used the
SetConsoleCtrlHandler()
API-call to intercept Ctrl-C and Ctrl-Break. This lets me exit what I am
doing in
 a controlled way, and works fine.

Under Windows 95, however, you can also interrupt a program by logging
off or shutting down Windows. According to the help files, you can use
ctrl-handlers to intercept these too... except that it doesn't work. The OS
just seems to call its own default handler in these cases no matter what
you do. It occurs to me that this could be a Windows-95-thing, and the
help files might be correct only for NT.

Could anyone with NT (and Win95?) test the following code snippet please?
I have disabled Ctrl-C, and given Close a little file-work to do;
Ctrl-Break
should work fine.

Thanks,
Chris.

----------------------------------------------------------------------------
--------------
{$APPTYPE Console}
program ExitProc;

uses
  Windows, SysUtils;

const TestFileName = 'C:\TestD2.tmp';

function CtrlHandler(const CtrlValue: Cardinal): BOOL; stdcall;
begin
  case CtrlValue of
    CTRL_C_EVENT: begin
                    Writeln( 'Control-C' );
                    Result := True;  // No more handlers
                    Exit
                  end;

    CTRL_CLOSE_EVENT: DeleteFile(TestFileName)
  end;
  Result := False  // Call default handler  
end;

var
  TestFile: File;
begin
{
  To see if the handler is called, give it some cleaning up to do

Quote
}

  AssignFile(TestFile, TestFileName);
  Rewrite(TestFile,1);
  CloseFile(TestFile);
{
  Now install the handler ...
Quote
}

  SetConsoleCtrlHandler(@CtrlHandler,True);
  while True do;
end.