How to Format a (Floppy) Disk

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


  • ERROR?

    Posted by biqi on 05/15/2005 11:03pm

    CFormatDriveDialog::~CFormatDriveDialog(void) { if (m_hHook != NULL) { UnhookWindowsHookEx(m_hHook); CFormatDriveDialog::m_hHook = NULL; } }

  • About a problem

    Posted by Legacy on 06/15/2003 12:00am

    Originally posted by: LeonOrient

    I downloaded your demo, which worked well.
    But after I created a WFC-AppWard project and added to the
    project the files: formatdrive.h and formatdrive.cpp , I
    compile the poject,
    the compiling result is: fatal error C1019:
    unexpected #else

    The position is at "#else" below:
    # include "StdAfx.h"
    # define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
    # include <afxwin.h> // MFC core and standard components

    What is wrong?(I used VC6)

  • As to the CD

    Posted by Legacy on 11/20/2002 12:00am

    Originally posted by: ZHEFU ZHANG

    Hi, Rino, Thanks for yr good sample.
    Do you have any idea to make CDFS on a CDR or even write data onto it? I have checked WinXP provide such interface. If you have any links to 3rd CDR SDK, pls tell me, thank you.
    With Regards,

  • It looks like it, but it is not the same

    Posted by Legacy on 11/04/2002 12:00am

    Originally posted by: Rino

    I have checked both tools and both tools look the same, but they are different. This tool is compatible with many Windows versions and the other tool does not run anywhere...

    Even the functionality is different. One tool disables all the fields on the Format dialog and the other tool only fills the volumename.

    Basicly both examples use the same concept with the WindowsHookEx, but that is just standard code that can be found on the site of MSDN-site of Microsoft.

    • Floppy Formatter

      Posted by asinha on 03/16/2005 12:47am


  • Similar to an existing article published elsewhere

    Posted by Legacy on 10/25/2002 12:00am

    Originally posted by: Ravi Bhavnani

    Seems awfully similar to this article:



Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

  • U.S. companies are desperately trying to recruit and hire skilled software engineers and developers, but there's simply not enough quality talent to go around. In response, companies often resort to inferior solutions -- hiring substandard developers and engineers, recruiting talent on a part-time or temporary basis, poaching people from competitors, or burdening an already stressed IT staff for more of their labor. Fortunately, there's a better solution. Read this white paper to learn the business value of …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date