From: bluestar on
Maybe it is a stupid question.

I want to do a function, like quick format

I have a idea that i use "CreateFile" to
open PhysicalDrive and write all zero
sectors by sectors until all size over.
But it will destroy all information,
including MBR and FAT32 Boot Record
, and spend much time to do.

How to do to let the function, like quick
format, avoid deleting MBR and and FAT32
Boot Record?

Not write all zero into sector 1 on each
drive(C:,D:) or on each PhysicalDrive,
right?
From: Joseph M. Newcomer on
Note that what you describe, to open PhysicalDriveN and write to it, is not the same as
"formatting". It is certainly the same as "erasing".

Why do you need to do this?

You need to look into the DeviceIoControl operations for file systems.
joe

On Sun, 4 May 2008 22:51:57 -0700 (PDT), bluestar <bluestar8783(a)gmail.com> wrote:

>Maybe it is a stupid question.
>
>I want to do a function, like quick format
>
>I have a idea that i use "CreateFile" to
>open PhysicalDrive and write all zero
>sectors by sectors until all size over.
>But it will destroy all information,
>including MBR and FAT32 Boot Record
>, and spend much time to do.
>
>How to do to let the function, like quick
>format, avoid deleting MBR and and FAT32
>Boot Record?
>
>Not write all zero into sector 1 on each
>drive(C:,D:) or on each PhysicalDrive,
>right?
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: foobar on

1. Use CreateProcess API to execute FORMAT command with correct
parameters.

2. When above approach is not sufficient, you use undocumented
FormatEx API. Long time ago there
was something called "fmifs.zip" or so available on the internet which
had source code of an example.


On May 5, 11:21 am, Joseph M. Newcomer <newco...(a)flounder.com> wrote:
> Note that what you describe, to open PhysicalDriveN and write to it, is not the same as
> "formatting". It is certainly the same as "erasing".
>
> Why do you need to do this?
>
> You need to look into the DeviceIoControl operations for file systems.
> joe
>
>
>
> On Sun, 4 May 2008 22:51:57 -0700 (PDT), bluestar <bluestar8...(a)gmail.com> wrote:
> >Maybe it is a stupid question.
>
> >I want to do a function, like quick format
>
> >I have a idea that i use "CreateFile" to
> >open PhysicalDrive and write all zero
> >sectors by sectors until all size over.
> >But it will destroy all information,
> >including MBR and FAT32 Boot Record
> >, and spend much time to do.
>
> >How to do to let the function, like quick
> >format, avoid deleting MBR and and FAT32
> >Boot Record?
>
> >Not write all zero into sector 1 on each
> >drive(C:,D:) or on each PhysicalDrive,
> >right?
>
> Joseph M. Newcomer [MVP]
> email: newco...(a)flounder.com
> Web:http://www.flounder.com
> MVP Tips:http://www.flounder.com/mvp_tips.htm

From: M. Shoaib Surya on
"bluestar" <bluestar8783(a)gmail.com> wrote in message
news:ee302aec-32de-4a34-b8b4-aa1d05da2346(a)p39g2000prm.googlegroups.com...
> Maybe it is a stupid question.
>
> I want to do a function, like quick format
>
> I have a idea that i use "CreateFile" to
> open PhysicalDrive and write all zero
> sectors by sectors until all size over.
> But it will destroy all information,
> including MBR and FAT32 Boot Record
> , and spend much time to do.
>
> How to do to let the function, like quick
> format, avoid deleting MBR and and FAT32
> Boot Record?
>
> Not write all zero into sector 1 on each
> drive(C:,D:) or on each PhysicalDrive,
> right?

See the post " How to format a volume" in
microsoft.public.win32.programmer.kernel
http://groups.google.com.pk/group/microsoft.public.win32.programmer.kernel/browse_thread/thread/58a4433670f29a91/de9ce0f381f21f7c?hl=en&lnk=st&q=%22How+to+format+a+volume%22#de9ce0f381f21f7c

- Shoaib


From: Joseph M. Newcomer on
The problem with using CreateProcess to create a cmd interpreter that runs a Format
command is that if anything goes wrong, you have no idea what happened. Using the APIs,
you usually know exactly what happened.
joe

On Mon, 5 May 2008 02:05:38 -0700 (PDT), foobar <somefoobar(a)gmail.com> wrote:

>
>1. Use CreateProcess API to execute FORMAT command with correct
>parameters.
>
>2. When above approach is not sufficient, you use undocumented
>FormatEx API. Long time ago there
>was something called "fmifs.zip" or so available on the internet which
>had source code of an example.
>
>
>On May 5, 11:21 am, Joseph M. Newcomer <newco...(a)flounder.com> wrote:
>> Note that what you describe, to open PhysicalDriveN and write to it, is not the same as
>> "formatting". It is certainly the same as "erasing".
>>
>> Why do you need to do this?
>>
>> You need to look into the DeviceIoControl operations for file systems.
>> joe
>>
>>
>>
>> On Sun, 4 May 2008 22:51:57 -0700 (PDT), bluestar <bluestar8...(a)gmail.com> wrote:
>> >Maybe it is a stupid question.
>>
>> >I want to do a function, like quick format
>>
>> >I have a idea that i use "CreateFile" to
>> >open PhysicalDrive and write all zero
>> >sectors by sectors until all size over.
>> >But it will destroy all information,
>> >including MBR and FAT32 Boot Record
>> >, and spend much time to do.
>>
>> >How to do to let the function, like quick
>> >format, avoid deleting MBR and and FAT32
>> >Boot Record?
>>
>> >Not write all zero into sector 1 on each
>> >drive(C:,D:) or on each PhysicalDrive,
>> >right?
>>
>> Joseph M. Newcomer [MVP]
>> email: newco...(a)flounder.com
>> Web:http://www.flounder.com
>> MVP Tips:http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm