Re: Format and quick format

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: William DePalo [MVP VC++] (willd.no.spam_at_mvps.org)
Date: 07/12/04


Date: Mon, 12 Jul 2004 13:39:22 -0400


"Paul" <Paul@discussions.microsoft.com> wrote in message
news:D7A159E0-F29E-4A25-82A1-2D0E988A7312@microsoft.com...
> What's the windows API to perform formatting or
> quick formatting of a floppy, a partition, or a volume?

I see that Dave has already pointed out the easiest way.

If you find that UI unacceptable then I think you are in for a lot of work.

On NT/2K/XP/2K+3 you can pass the name of a floppy drive, e.g. \\.\A: (or in
source code where backslashes must be doubled up "\\\\.\\A:") to
CreateFile(). Then to write to sector number n you write to the device
handle at an offset given by the product of the sector number n and the size
of one sector. Note this caveat from the docs:

<quote>
Note that all I/O buffers should be sector aligned (aligned on addresses in
memory that are integer multiples of the volume's sector size), even if the
disk device is opened without the FILE_FLAG_NO_BUFFERING flag. Depending the
disk, this requirement may not be enforced.
</quote>

To do this, you'll need to be aware of the layout of the MBR, the FAT table,
the root directory etc. It's a trip down memory lane. :-)

On 95/98/Me I think what you have to do is to get yourself a DOS reference
such as Ralf Brown's interrupt list and use DeviceIOControl() to issue DOS
interrupt functions (int 21h) to the virtual device driver in question. The
technique is sketched here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/calling_deviceiocontrol_on_windows_95_98_me.asp

As above, you'll need to know the layout of the disk.

You may want to post again in the kernel group to find out if there is an
easier alternative.

Regards,
Will



Relevant Pages

  • Re: BSDInstaller snapshot
    ... The commands run after the formatting appear to be the same as is run after ... better to be always changed to the disk name. ... does/will BSDInstaller support a DD ... 'start sector', 'end sector' and 'size in sectors'. ...
    (freebsd-current)
  • Re: Format Program for a floppy disk for an OSless envirnorment
    ... >> happenig when u format a disk? ... > to place on the floppy. ... "formatting" but really mean "creating a file system" on a disk? ... "here ends a sector". ...
    (comp.programming)
  • Re: Magic 5 or 6
    ... I scanned the HD and the disk is fine sector ... Formatting a hard disk drive that has no bad sectors ... >operating system. ...
    (comp.sys.atari.st)
  • Re: Format and quick format
    ... >> quick formatting of a floppy, a partition, or a volume? ... Then to write to sector number n you write to the device ... you'll need to know the layout of the disk. ...
    (microsoft.public.vc.language)
  • Re: SortMerge avoids thrashing (was: Baileys "two pass" FFT algorithm question)
    ... of size that match the backing store to assure locality of reference. ... For RAM backed by disk, the key thing which takes the most time is ... you need to localize sector reads within that one ... Sweeps your RAM once when you load original data from disk. ...
    (comp.programming)