🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to verify a file is not opened in EXCEL

#5549
From: Tom Woodrow
Date: Sat, 06 Aug 2005 17:27
44 lines
2135 bytes
Vladimir,

Thanks for the suggestions. First I use FileExists to verify the file 
than use the IfFileOccupied routine from the URL you sent me. I opened a 
file with EXCEL and then tested it with IsFileOccupied (below) and get 
the EFOpenError exception. It works ok and returns false if the file is 
not opened. For some rason the try/catch mechanism is not working here.

Any suggestions?

Thanks
Tom Woodrow


bool IsFileOccupied( const char* s )
{
    try
    {
       TFileStream *tStream = new TFileStream( AnsiString( s ),

fmOpenRead|fmShareExclusive );
       delete tStream;
       return( false );
    }
    catch ( const Exception& )
    {
       return( true );
    }

}


Vladimir Stefanovic wrote:
> I'm not sure how to check if it's opened by EXCEL
> but I know how to check if it is opened by some
> other program.
> 
> Look at:
> http://tinyurl.com/75nlq
> 
> There is a routine IsFileOccupied(). Also this routine
> must be executed after checking if file exists, etc...
> 
> 
Technical Details
Message-ID: <42f4f2f6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42f4520f$1@newsgroups.borland.com> <42f45f75$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8c4c5257256193cf
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Sat, 06 Aug 2005 10:27:18 -0700
From: Tom Woodrow <tomwoodrow@comcast.net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: How to verify a file is not opened in EXCEL
References: <42f4520f$1@newsgroups.borland.com> <42f45f75$1@newsgroups.borland.com>
In-Reply-To: <42f45f75$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.6.92.22
Message-ID: <42f4f2f6$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1123349238 24.6.92.22 (6 Aug 2005 10:27:18 -0700)
Lines: 44
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail