Paul
Tue Jul 13 01:29:02 CDT 2004
Hmmm... pretty complicated, huh? Igor replied something about IOCTL_DISK_FORMAT_TRACKS[_EX], but according to MSDN it's only for formatting a floppy. I need something that also works for a partition or a mounted volume.
Thanks anyway for your reply!
-P
"William DePalo [MVP VC++]" wrote:
> "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
>
>
>