Sign in to follow this  
Sephirox

write floppy's track 1 using dev c++

Recommended Posts

hi, im trying to write to the first track of a floppy...ive seen examples using djgpp, but id like to do it using dev c++...basically, i need to write 512 bytes to the first track of a floppy (so i can boot from it), thx in advance

Share this post


Link to post
Share on other sites
I believe CreateFile with a file name of "\\.\A:" will allow access to the drive for writing and reading, at least in VC.

Share this post


Link to post
Share on other sites
yes, but, will it be on the first sector of the first track? i need to make sure my 512 byte program is in the first 512 bytes of the disk ( i need to write to the disk starting at offset 0)

Share this post


Link to post
Share on other sites
Your in luck. The API is Identical :)

Just try and run some samples (assuming everything links and compiles correctly).

I use VS.NET primarily but the other app is nice in its own right.

Share this post


Link to post
Share on other sites
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp

The msdn link to that function. As far as I can tell (in past experience also) is that it opens up the actual physical drive for reading/writing. Which should give you the very first area of the disk.

I believe this is the lowest level you can get with Windows, but could be wrong. You should just try and see :)

Share this post


Link to post
Share on other sites
Here's a document detailing the FAT12 file system which is what floppy disks uses. You don't need to read the whole document - the structure of the first 512 bytes (the bootsector) is listed fairly early on so you can skip the rest: clicky (the document covers all FAT filesystems - 12/16 and 32).

To access the floppy disk as a file you can open it like so:
FILE *FilePtr = fopen("\\\\.\\a:", "wb");

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this