Click to See Complete Forum and Search --> : Format disk programmatically


Hardeep Singh
April 13th, 1999, 10:25 AM
How do I bring up the format disk dialog box from my program?

Vasko
April 14th, 1999, 02:13 AM
SHFormatDrive pops the standard Windows format dialog.

extern "C" {
WINBASEAPI
LONG
WINAPI SHFormatDrive( HWND hParent , LONG drive, LONG p3, LONG p4);
}
from SHELL32.DLL

hParent = parent window hwnd
drive = A: 0, B: 1, C: 2, etc.

you have to experiment with it a little.
Have in mind that it is undocumented (you will not find it in header files or documentation). And returns different values on 95 and NT:
Under NT it returns nonzero on success. The third and fourth paramters are not used on NT (or i do not know what they are used for - however NT's WinDisk calls it with p3=0xFFFF, p4 = 0)

Under 95 it returns 0 on success. The p3 (or p4) parameter tell the system to format the disk with system files (quick format etc.)

By all means you should investigate the problem because right now I do not have my sources to be more specific.