How to Format a (Floppy) Disk

Tuesday Nov 19th 2002 by Remy Böhmer

Learn how to format a floppy on all Microsoft Windows versions released since Windows 95. (Uses the SHFormatDrive method of the Shell32.dll.)

Click here for a larger image.

Environment: VC6 SP5; it is suitable for Windows 95/98/NT4/2000/XP

This example shows how to call the Shell Format routine (SHFormatDrive from the Shell32.dll library).

Normally, when you call this method, the dialog itself is not configured according to your preferred defaults. This demo shows how to call this routine and how to configure it before the dialog is painted. It also disables certain fields so that the user cannot modify them. The difficulty in this sample is the support for many Windows versions. Each Windows version handles this routine differently; even the API and the dialog itself are different for the different Windows versions....

This sample can handle them all! (Windows 95OSR1, 95OSR2, 98, 98SE, NT4, 2000, and XP) The remaining Windows versions are excluded now by code, but in the near future this will be expanded for ALL English Windows versions released since Windows 95.

The code is entirely located in one Class, which is stored in the FormatDrive.h/cpp files. The remaining files are only used for building up this Demo. Below an example is given that shows how to call the routines in the Class.

// The following two lines are BOTH needed to initialise
// the Format Dialog
CFormatDriveDialog dlg;
Result = dlg.DoModal(AfxGetMainWnd()->m_hWnd,'A',/*
         QuickFormat */ true, "VolumeLabel");

// When formatting is finished, aborted, or cancelled,
// the function DoModal returns
switch (Result)
   case IDOK:
      MessageBox("The main dialog has detected that Format was
                  completed successfully");
   case IDCANCEL:
      MessageBox("The main dialog has detected that Format was
   case IDABORT:
      MessageBox("The main dialog has detected that Format has
                  failed to load the dependant libraries");


Download demo project (Source included) - 21 Kb
Mobile Site | Full Site
Copyright 2018 © QuinStreet Inc. All Rights Reserved