[ Home | Contents | Search | Next | Previous | Up ]
Date: 12/1/99
Time: 10:22:24 PM
How do I format a drive programmatically?
There is a semidocumented function ShFormatDrive that calls up the format dialog.
it uses the following constants:
// Standard Format Identifier
#define SHFMT_ID_DEFAULT = 0xFFFF;
// Option values
#define SHFMT_OPT_QUICKFORMAT = 0x0000;
#define SHFMT_OPT_FULL = 0x0001;
#define SHFMT_OPT_SYSONLY = 0x0002;
// Return values
#define SHFMT_ERROR = 0xFFFFFFFF;
#define SHFMT_CANCEL = 0xFFFFFFFE;
#define SHFMT_NOFORMAT = 0xFFFFFFFD;
extern "C" __declspec(dllimport) WINAPI
int SHFormatDrive(HWND hWnd, WORD Drive, int fmtID, WORD Options);
void TYourClass::Button1Click()
{
SHFormatDrive(Handle,
0
/* Drive 'a:' */,
SHFMT_ID_DEFAULT,
OPTION_DEFAULT);
}