Article View: borland.public.cppbuilder.nativeapi
Article #8315Re: floppy disk bad sectors
From: Andrue Cope [TeamB]
Date: Thu, 11 Nov 2004 16:31
Date: Thu, 11 Nov 2004 16:31
45 lines
2310 bytes
2310 bytes
Okay this routine will check a 1.4MB floppy disk:
Note my corrections to your CreateFile() call.
bool diskIsGood()
{
HANDLE fileHandle = CreateFile("\\\\.\\a:",
GENERIC_WRITE|GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_ALWAYS,
0,
NULL);
BYTE buffer[ 512 ];
// Experimental, didn't work. I'm looking into this now.
DWORD blockTotal=GetFileSize( fileHandle, NULL );
for( DWORD blockNumber=0;
blockNumber<2880;
++blockNumber )
{
SetFilePointer( fileHandle,
blockNumber*DWORD( 512 ),
NULL,
FILE_BEGIN );
DWORD bytesRead=0;
if( !ReadFile( fileHandle,
buffer,
512,
&bytesRead,
NULL ) )
return false;
}
return true;
}
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<419394a0$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!63.218.45.10.MISMATCH!newshosting.com!nx01.iad01.newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<419121f3$1@newsgroups.borland.com> <41921bba$1@newsgroups.borland.com> <41922983$1@newsgroups.borland.com> <4192311f$1@newsgroups.borland.com> <41923ebd@newsgroups.borland.com> <41937d68@newsgroups.borland.com> <4193841f@newsgroups.borland.com> <419387ad$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2aacc4eb93e0b7a0 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Andrue Cope [TeamB]" <no.spam@not.a.valid.address> Subject: Re: floppy disk bad sectors Newsgroups: borland.public.cppbuilder.nativeapi References: <419121f3$1@newsgroups.borland.com> <41921bba$1@newsgroups.borland.com> <41922983$1@newsgroups.borland.com> <4192311f$1@newsgroups.borland.com> <41923ebd@newsgroups.borland.com> <41937d68@newsgroups.borland.com> <4193841f@newsgroups.borland.com> <419387ad$1@newsgroups.borland.com> Date: Thu, 11 Nov 2004 16:31:25 +0000 User-Agent: XanaNews/1.16.4.6 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 NNTP-Posting-Host: 217.207.223.34 Message-ID: <419394a0$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1100190880 217.207.223.34 (11 Nov 2004 08:34:40 -0700) Lines: 45 X-Authenticated-User: acope Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!63.218.45.10.MISMATCH!newshosting.com!nx01.iad01.newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail