Article View: borland.public.cppbuilder.nativeapi
Article #5008Re: directory list problems
From: Alan Bellingham
Date: Wed, 26 Oct 2005 09:46
Date: Wed, 26 Oct 2005 09:46
41 lines
2706 bytes
2706 bytes
"robert" <rob@no-spam.boo> wrote:
>I am writing a program to list a whole directory, and of course I have one problem. When I call the routing the first time it is perfect, but the others time I try to call the same routine It doesn't work: "GetLastError" is == ERROR_NO_MORE_FILES ! Why that ? I have to reset something ?
(Could you set your line width according to forum rules please?)
> String temp;
> while(GetLastError() != ERROR_NO_MORE_FILES)
> {
> ........ my code here
> FindNextFile(hFind, &FileData);
> }
> FindClose(hFind); // Free the dir structure
>}
GetLastError() does not say "tell me what error I had in what I last
did". It says "when I last had an error, what was it?".
If nothing else caused an error after you called it the first time, then
next time in, the last error will still be what caused an error last
time in.
When Gambit says "Not every API operation resets GetLastError()", he
understates the case. According to MSDN 2003:
Most functions call SetLastError when they fail. Function failure is
typically indicated by a return value error code such as zero, NULL,
or �1. Some functions call SetLastError under conditions of success;
those cases are noted in each function's reference topic."
When I then searched for any such functions, I came up blank. I
therefore take the above "some functions" to be a getout in case
Microsoft ever accidentally do produce such a function, not because they
yet have.
(Of course, they may be counter examples. I just didn't find any.)
Alan Bellingham
--
ACCU Conference 2006 - 19-22 April, Randolph Hotel, Oxford, UK
Technical Details
Message-ID:
<scjul1p7qhl0g4m5etc84s5g5fjmoqufcs@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.inode.at!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<435e6c76$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fb06c70f9d4d1eee X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII From: Alan Bellingham <alanb@episys.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: directory list problems Date: Wed, 26 Oct 2005 10:46:34 +0100 Reply-To: alanb@episys.com Message-ID: <scjul1p7qhl0g4m5etc84s5g5fjmoqufcs@4ax.com> References: <435e6c76$1@newsgroups.borland.com> X-Newsreader: Forte Agent 3.1/32.783 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 193.129.251.253 X-Trace: newsgroups.borland.com 1130319811 193.129.251.253 (26 Oct 2005 02:43:31 -0700) Lines: 41 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.inode.at!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail