Initialising a floppy disk using Win32 API

Windows specific forum
User avatar
Dreamland Fantasy
Enthusiast
Enthusiast
Posts: 335
Joined: Fri Jun 11, 2004 9:35 pm
Location: Glasgow, UK
Contact:

Initialising a floppy disk using Win32 API

Post by Dreamland Fantasy »

Hi there,

I have been experimenting with some disk routines programmed using the Windows API (IOCTL). I have been able to successfully format and verify floppy disks, but I am unable to initialise them with the FAT, etc. I have been trying to use IOCTL_DISK_CREATE_DISK which works for things like compact flash cards, but not floppies which throws up a "The request is not supported" error.

Does anyone know how I can initialise a floppy disk for use using the Windows API?

Kind regards,

Francis
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Initialising a floppy disk using Win32 API

Post by IdeasVacuum »

able to successfully format
Sounds like you are nearly there - have you searched the forum? I remember someone trying to do the same thing about a year or so ago. I assume the Windows API still supports floppy disks.....
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Dreamland Fantasy
Enthusiast
Enthusiast
Posts: 335
Joined: Fri Jun 11, 2004 9:35 pm
Location: Glasgow, UK
Contact:

Re: Initialising a floppy disk using Win32 API

Post by Dreamland Fantasy »

IdeasVacuum wrote:
able to successfully format
Sounds like you are nearly there - have you searched the forum? I remember someone trying to do the same thing about a year or so ago. I assume the Windows API still supports floppy disks.....
I have searched the forum, but the only thing I found was using the fmifs.dll which doesn't give me the level of control I am looking for. I'm assuming that the Windows API still supports floppy disks to some degree as I can still format floppies through explorer, but who knows.

Kind regards,

Francis
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Initialising a floppy disk using Win32 API

Post by IdeasVacuum »

What are you using to do the format, Windows Shell? SHFormatDrive()? I thought that might be good but it's depreciated.

Again old, but interesting: NTAPI Edit: No, it isn't, sorry.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Dreamland Fantasy
Enthusiast
Enthusiast
Posts: 335
Joined: Fri Jun 11, 2004 9:35 pm
Location: Glasgow, UK
Contact:

Re: Initialising a floppy disk using Win32 API

Post by Dreamland Fantasy »

I'm using the IOCTL functions such as IOCTL_DISK_FORMAT_TRACKS which are called under DeviceIoControl().

Kind regards,

Francis
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Initialising a floppy disk using Win32 API

Post by IdeasVacuum »

IdeasVacuum
If it sounds simple, you have not grasped the complexity.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Re: Initialising a floppy disk using Win32 API

Post by RASHAD »

How about
for all windows versions

Code: Select all

RunProgram("Format"," a: /V:Test /F:1.44 /S","")
Egypt my love
User avatar
Dreamland Fantasy
Enthusiast
Enthusiast
Posts: 335
Joined: Fri Jun 11, 2004 9:35 pm
Location: Glasgow, UK
Contact:

Re: Initialising a floppy disk using Win32 API

Post by Dreamland Fantasy »

IdeasVacuum wrote:Take a look at this: https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
I did look at this earlier, but I wasn't sure how to implement it in PB. I'll give it another look tomorrow.

Kind regards,

Francis
User avatar
Dreamland Fantasy
Enthusiast
Enthusiast
Posts: 335
Joined: Fri Jun 11, 2004 9:35 pm
Location: Glasgow, UK
Contact:

Re: Initialising a floppy disk using Win32 API

Post by Dreamland Fantasy »

RASHAD wrote:How about
for all windows versions

Code: Select all

RunProgram("Format"," a: /V:Test /F:1.44 /S","")
Thanks, but that doesn't give me the level of control that I am looking for.

Kind regards,

Francis
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Initialising a floppy disk using Win32 API

Post by IdeasVacuum »

It is worth sending a pm to JHPJHP - may have experience in this area.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: Initialising a floppy disk using Win32 API

Post by heartbone »

Dreamland Fantasy wrote:Hi there,

I have been experimenting with some disk routines programmed using the Windows API (IOCTL). I have been able to successfully format and verify floppy disks, but I am unable to initialise them with the FAT, etc. I have been trying to use IOCTL_DISK_CREATE_DISK which works for things like compact flash cards, but not floppies which throws up a "The request is not supported" error.

Does anyone know how I can initialise a floppy disk for use using the Windows API?

Kind regards,

Francis
Isn't formatting the same as initializing a floppy? :?

FAT12 remains in use on all common floppy disks, including 1.44 MB and later 2.88 MB disks (media descriptor byte 0xF0).

I'm probably missing something, or perhaps it's mounting a floppy drive that you seek?
Keep it BASIC.
User avatar
Dreamland Fantasy
Enthusiast
Enthusiast
Posts: 335
Joined: Fri Jun 11, 2004 9:35 pm
Location: Glasgow, UK
Contact:

Re: Initialising a floppy disk using Win32 API

Post by Dreamland Fantasy »

Formatting a disk, from the point of view of the IOCTL_DISK_FORMAT_TRACKS function, only formats the tracks.

Initialising (perhaps I'm using the wrong term here) the disk sets up the file system. Unless the disk is initialised it will not be accessible to Windows.

Kind regards,

Francis
fryquez
Enthusiast
Enthusiast
Posts: 391
Joined: Mon Dec 21, 2015 8:12 pm

Re: Initialising a floppy disk using Win32 API

Post by fryquez »

There is some nice source code: Floppy Disk Format
It creates FAT12 for manually, but only supports the default 1.44 MB floppy.

Have to ask, why in the year 2016 you need floppies :shock:
User avatar
Dreamland Fantasy
Enthusiast
Enthusiast
Posts: 335
Joined: Fri Jun 11, 2004 9:35 pm
Location: Glasgow, UK
Contact:

Re: Initialising a floppy disk using Win32 API

Post by Dreamland Fantasy »

fryquez wrote:There is some nice source code: Floppy Disk Format
It creates FAT12 for manually, but only supports the default 1.44 MB floppy.

Have to ask, why in the year 2016 you need floppies :shock:
Thanks for that link. Although it might be more complicated that doing a IOCTL_DISK_CREATE_DISK call, it may be just what I am looking for! :)

As for why I need floppies, I still use them for my Amigas (3.5") and BBC Micro (5.25" & 3.5"), plus my music keyboards uses 3.5" floppies. ;)

Kind regards,

Francis
User avatar
JHPJHP
Addict
Addict
Posts: 2273
Joined: Sat Oct 09, 2010 3:47 am

Re: Initialising a floppy disk using Win32 API

Post by JHPJHP »

Hi Dreamland Fantasy,

I included an example in my Services, Stuff, and Shellhook post that may provide a solution.
- Stuff\OtherStuff\FormatDevice.pb
Last edited by JHPJHP on Sat Feb 13, 2016 8:04 pm, edited 3 times in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Post Reply