🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: log off/ application terminate

#16003
From: Duane Hebert
Date: Tue, 03 Jun 2003 20:34
77 lines
3358 bytes
"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3edd00ef$2@newsgroups.borland.com...
>
> "Duane Hebert" <duane@nitrex.com> wrote in message
> news:3edcf095$3@newsgroups.borland.com...
>
> > I'll have to do some more testing but it
> > doesn't seem like the dtor is being called.
>
> I can assure that that until normal conditions, it does.  If it is not,
then
> you must be doing something else in your code to cause the process to
> terminate prematurely.  If you can reproduce it, then please provide a
> complete snippet of test code that reproduces the problem.

I created a new application.  I added a function that we generally use
to write to files.  I use it in the dtor.  On close it works as expected.
I logoff and it doesn't write the file.  I'm actually doing this at my desk.
I was pretty surprised.

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

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include <memory>
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;


// AnsiString version of Xprtf using TFileStream
int Xprtf(AnsiString output, AnsiString filename, long filesize) {

     try {
        int FileMode;
        if(!FileExists(filename)) FileMode = fmCreate|fmShareDenyWrite;
        else FileMode = fmOpenReadWrite|fmShareDenyWrite;

        std::auto_ptr<TFileStream>Infile(new
TFileStream(filename,FileMode));
        if(Infile->Size < filesize || !filesize) Infile->Position =
Infile->Size;
        else {
                Infile->Position = 0;
                Infile->Size = 0;
        }
        Infile->WriteBuffer(static_cast<void*>(output.c_str()),
output.Length());
     }catch (Exception &e) {
        return -1;
     }

     return 0;

}

//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//--------------------------------------------------------------------------
-

__fastcall TForm1::~TForm1() {

    Xprtf("Dtor Called\r\n","c:\\spoo.txt");


}
Technical Details
Message-ID: <3edd0644$2@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3edccd80@newsgroups.borland.com> <3edcd422$1@newsgroups.borland.com> <3edcdbb6@newsgroups.borland.com> <3edcea6f$1@newsgroups.borland.com> <3edcf095$3@newsgroups.borland.com> <3edd00ef$2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,f4b8abe1a2fab575
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-06-03 13:41:08 PST
From: "Duane Hebert" <duane@nitrex.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3edccd80@newsgroups.borland.com> <3edcd422$1@newsgroups.borland.com> <3edcdbb6@newsgroups.borland.com> <3edcea6f$1@newsgroups.borland.com> <3edcf095$3@newsgroups.borland.com> <3edd00ef$2@newsgroups.borland.com>
Subject: Re: log off/ application terminate
Date: Tue, 3 Jun 2003 16:34:13 -0400
Lines: 79
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 199.243.88.188
Message-ID: <3edd0644$2@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1054672452 199.243.88.188 (3 Jun 2003 13:34:12 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail