Board index » Visual Studio » Problem opening CD-Rom File with MFC

Problem opening CD-Rom File with MFC

Visual Studio132
Hi,



I'm using VC.Net 2003 and I'm getting an exception thrown when I try to open

a file on a CD. It reproduces on an empty, wizard-generated, MDI, Doc-View

project and happens on Win2k and XP. This happens with the following stack:



ATL::CTime::CTime(const _FILETIME&, ...

CFile::GetStatus()

CFile::GetFilePath()

CArchive::CArchive()

CDocument::OnOpenDocument()

etc.



What happens is that GetStatus calls ::GetFileTime() which returns a zero

value for the last access time which seems reasonable for a CD. The CTime

constructor passes the zero value to ::FileTimeToLocalFileTime() which

returns a garbage value (ffff ffbc f1dc c000) without complaint. This value

is passed to ::FileTimeToSystemTime() which fails causing the constructor to

throw the exception.



This seems kind of basic for such well used code. Should I not expect to

open CD files?



Thanks


-
 

Re:Problem opening CD-Rom File with MFC

Bill Below wrote:



Quote
Hi,



I'm using VC.Net 2003 and I'm getting an exception thrown when I try to open

a file on a CD. It reproduces on an empty, wizard-generated, MDI, Doc-View

project and happens on Win2k and XP. This happens with the following stack:



I don't have a reference or link for you, but this problem has been

reported before in this newsgroup as a bug in VC.Net 2003. My

recollection is that there is no reasonable workaround (except going

back to good old VC6).



--

Scott McPhillips [VC++ MVP]



-

Re:Problem opening CD-Rom File with MFC

Thanks, Scott



I knew this couldn't have gone unnoticed but I couldn't find a post or KB

either. I guess I can override OnOpenDocument() where the CFile is

constructed and check for a null access time and at least give the user a

more useful error message. Or maybe I could copy the CD file to a disk file

and let the user look at that. This would probably open other cans of worms

and is certainly beyond what I would call a reasonable workaround.



Bill





"Scott McPhillips [MVP]" wrote:



Quote
Bill Below wrote:



>Hi,

>

>I'm using VC.Net 2003 and I'm getting an exception thrown when I try to open

>a file on a CD. It reproduces on an empty, wizard-generated, MDI, Doc-View

>project and happens on Win2k and XP. This happens with the following stack:



I don't have a reference or link for you, but this problem has been

reported before in this newsgroup as a bug in VC.Net 2003. My

recollection is that there is no reasonable workaround (except going

back to good old VC6).



--

Scott McPhillips [VC++ MVP]





-

Re:Problem opening CD-Rom File with MFC

"Scott McPhillips [MVP]" wrote:

Quote
Bill Below wrote:



>Hi,

>

>I'm using VC.Net 2003 and I'm getting an exception thrown when I try to open

>a file on a CD. It reproduces on an empty, wizard-generated, MDI, Doc-View

>project and happens on Win2k and XP. This happens with the following stack:



I don't have a reference or link for you, but this problem has been

reported before in this newsgroup as a bug in VC.Net 2003. My

recollection is that there is no reasonable workaround (except going

back to good old VC6).



I reported that - and I'm sad to report the bug still exists in VC8 (just

discovered that this past weekend). There was code added in VC8 (a call to

CTime::IsValidFILETIME) however, I'm finding situations where that call

succeeds, but the CTime constructor still throws an exception. My work around

so far is to copy CFile::GetStatus and change the code by adding a

try/catch(COleException*) block around the CTime ctor (for each of the 3 time

fields). I then change all my code to call my local getstatus function. So

far, I haven't run into an issue where some embedded code call GetStatus

(guess I'm lucky). Ultiimately, it seems the fix should be the validition

code for CTime(FILETIME) and CTime::IsValidFILETIME() should be the same.



Dave Connet

Entelos, Inc.

-

Re:Problem opening CD-Rom File with MFC

Quote
I reported that - and I'm sad to report the bug still exists in VC8 (just

discovered that this past weekend). There was code added in VC8 (a call to

CTime::IsValidFILETIME) however, I'm finding situations where that call

succeeds, but the CTime constructor still throws an exception.



Dave,



If you have a reproducible case for this, please submit a bug report

for it at:



lab.msdn.microsoft.com/productfeedback/">lab.msdn.microsoft.com/productfeedback/



... if you haven't already done so.



Dave Lowndes

-