Article View: borland.public.cppbuilder.nativeapi
Article #2095Error handling Flash Card Reader?
From: Bob Reeves
Date: Wed, 02 May 2007 15:23
Date: Wed, 02 May 2007 15:23
32 lines
2025 bytes
2025 bytes
Hoping this is a good place to post this..
I am accessing image files from a USB Compact Flash card reader and need to
catch the error if a flash card isn't in the reader.
Here is what I am trying to do, please assume all variables have been
declared and initialized..
old_err_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
SetLastError(-1);
dn = findfirst(FileName,&ffblk,0); // find first file
er = GetLastError();
if(er != -1) {
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, er, 0, buffer,
sizeof(buffer), 0);
ShowMsg("Unable to read Memory Card");
ShowMsg(buffer);
}
SetErrorMode(old_err_mode);
This works fine, catches the error and reports as expected, however if I
then insert a memory card into the reader and call the above code again it
gives me an invalid handle error. If I shut down and re-start the app it
will read the card without the error.
Looking like I missed re-setting something that will allow it to try to read
the drive the second time. Any ideas on what I need to do eliminate the
invalid handle error?
Thanks,
Bob
Technical Details
Message-ID:
<4638ae13$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,189da4c7c99990ac,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Bob Reeves" <bob@somethinxtra.com> From: "Bob Reeves" <bob@somethinxtra.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Error handling Flash Card Reader? Date: Wed, 2 May 2007 10:23:00 -0500 Lines: 34 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 70.184.20.29 Message-ID: <4638ae13$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1178119699 70.184.20.29 (2 May 2007 08:28:19 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail