Главная страница | назад





Article #17540: How to format a drive programmatically

 Question and Answer Database
FAQ2540C.txt How to format a drive programmatically
Category :Windows API
Platform :All
Product :C++Builder ALL
Question:
How do I format a drive programmatically?
Answer:
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 __fastcall TYourClass::Button1Click(TObject *Sender)
{
SHFormatDrive(Handle, 0 /* Drive 'a:' */, SHFMT_ID_DEFAULT, OPTION_DEFAULT);
}
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99