Thread: Floppys

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    183

    Floppys

    I know. Yet another thread from me.

    I was just wondering if there's a way to check if a floppy is in the A drive in C++.

    (Preferably fit for use in a loop.)

    Code:
    While ( Floppy isn't found )
    {
            cout<<"Please insert a disk";
    }
    Some thing like that.
    Thanks in advance for any replies.

  2. #2
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    I haven't worked with them but you could try changing directory to "A:\" and then check whether or not the function failed.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    Sounds good.
    Care to expand ?

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    Guess not ...

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    The fact that he is offline may have something to do with it

  6. #6
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Sounds more like windows programming

  7. #7
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    Well, if you try to access A:\ in Windows without having a floppy in it you'll get errors and get thrown back to the directory you came from. It seems obvious to me that a SetCurrentDirectory() call would also fail if you did the same.

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Unlike USB the floppy drive doesn't notify the OS of a disk being inserted or removed. This means the only way to you'll know there is as disk in the drive is to try and access it. If you did this in a loop you'd have constant disk access but you would be prompted to insert a disk if non were insertd.

    I don't see why you'd need to worry about this. Just treat accessing files on a floppy like any other files and let the OS tell the user when to insert a floppy.

  9. #9
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Quote Originally Posted by swgh
    Sounds more like windows programming
    Haha, I always associate Floppy Disks with DOS ...

  10. #10
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    Quote Originally Posted by Quantum1024
    I don't see why you'd need to worry about this. Just treat accessing files on a floppy like any other files and let the OS tell the user when to insert a floppy.
    I do see what you mean. However, I am trying to compare a string to another string stored in a text file on a floppy. If I let windows tell the user to insert a floppy, then the user could simply press continue, and the string would not be read, causing the variable I was gonna store it in to equal 0. I can't think of any other way to stop windows interfereing (interfereing ?) than to have the program to check for a disk instead.

    Anyway ta for your replies.

  11. #11
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    Who uses floppy discs anyway?

  12. #12
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    People like me.

  13. #13
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    http://www.codeguru.com/forum/showthread.php?t=372265

    Code:
    int floppyInDriveA()
    {
    	HANDLE hDrive;
    	DISK_GEOMETRY Geometry;
    	int returnVal = 1;
    
    	hDrive = CreateFile("\\\\.\\A:",
    		GENERIC_READ | GENERIC_WRITE,
    		FILE_SHARE_READ | FILE_SHARE_WRITE,
    		NULL, OPEN_EXISTING,
    		0, NULL);
    
    	if( !GetDiskGeometry(hDrive, &Geometry))
    	{
    		retval =  0;
    	}
    
    	CloseHandle(hDrive);
    	return retval;
    }
    
    
    
    int GetDiskGeometry(HANDLE hDisk, PDISK_GEOMETRY lpGeometry )
    {
    	DWORD ReturnedByteCount;
    
    	return DeviceIoControl(
    		hDisk,
    		IOCTL_DISK_GET_DRIVE_GEOMETRY,
    		NULL,
    		0,
    		lpGeometry,
    		sizeof(*lpGeometry),
    		&ReturnedByteCount,
    		NULL
    	);
    }

  14. #14
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quote Originally Posted by bumfluff
    Who uses floppy discs anyway?
    I hate floppies ever since my data was lost and I realized how fragile these things are, even when just stored away for 7 years.

  15. #15
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    499
    They're the only way I can transfer files from my 68k mac .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using Floppy's and CD ROM's in Slackware Linux?
    By drdroid in forum Tech Board
    Replies: 5
    Last Post: 04-09-2003, 01:39 AM
  2. floppy drives...
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 39
    Last Post: 11-16-2001, 06:49 PM