You're here: Snippet Directory » C/C++ (495)
Language:

Is floppy ready

Language: English
Programming Language: C
Published by: theflyguy [not registered]
Last Update: 5/15/2006
Views: 155


Description

Very simple WIN32 API call sample to determine whether your floppy drive is ready and has a disc inserted

Code

1 /* 2 * Returns true if specified floppy drive is ready with a with a diskette 3 * inserted, otherwise false. 4 * drive: must be 1 for drive a or 2 for drive B 5 * 6 * by Alessandro Antonini "theflyguy" - www.futurtechno.com/centralpark 7 */ 8 #include <stdio.h> 9 #include <windows.h> 10 int FloppyReady(BYTE drive) 11 { 12 WORD SaveErrorMode; 13 int result = FALSE; /* assume errors */ 14 if (1!=drive || 2!=drive) 15 return result; /* invalid drive number passed */ 16 17 SaveErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); 18 if (DiskFree(drive) != -1) result = TRUE; 19 SetErrorMode(SaveErrorMode); 20 return result; 21 } 22 23 int main( int argc, char **argv ) 24 { 25 printf( "Floppy drive A is %s\n", FloppyReady(1) ? "ready":"not ready"); 26 return 0; 27 }

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS