🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12737

Access violation when closing console app with Ctrl-C.

#12737
From: Melvin Holt
Date: Wed, 19 Nov 2003 16:09
54 lines
2370 bytes
I am having trouble with a console application generating an access
violation if either the close box is clicked or a Ctrl-C is received.
I have finally worked things down to the following trivial
applications.

This one works (closes on Ctrl-C or clicking the close box).

//---------------------------------------------------------------------------

#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{
  for (;;);
  return 0;
}
//---------------------------------------------------------------------------


This one commits an access error on either event.

//---------------------------------------------------------------------------

#include <Printers.hpp>
#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{
  TPrinter* prtr = Printer();
  for (;;);
  return 0;
}
//---------------------------------------------------------------------------

I am porting an old DOS application to a windows console app, and was
using the TPrinters class to handle printing requirements for the
application.

I have tried using SetConsoleCtrlHandler() to install a handler for
these events, and shows that the violation occurs when ExitProcess()
is called.

Does anyone have a suggestion on why this occurs, and how to handle
it? I am using Builder 5.

Thanks for any assistance.

Melvin Holt
Technical Details
Message-ID: <a7b0d595.0311190809.109adfd@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,da070ad714c2bd10,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-19 08:09:58 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
From: MelvinRHoltJr@Yahoo.com (Melvin Holt)
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Access violation when closing console app with Ctrl-C.
Date: 19 Nov 2003 08:09:57 -0800
Organization: http://groups.google.com
Lines: 54
Message-ID: <a7b0d595.0311190809.109adfd@posting.google.com>
NNTP-Posting-Host: 65.122.76.60
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1069258197 5068 127.0.0.1 (19 Nov 2003 16:09:57 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 19 Nov 2003 16:09:57 +0000 (UTC)