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"); break; case IDCANCEL: MessageBox("The main dialog has detected that Format was Cancelled"); break; case IDABORT: MessageBox("The main dialog has detected that Format has failed to load the dependant libraries"); break; default: ASSERT(FALSE); break; }

Comments
ERROR?
Posted by biqi on 05/15/2005 11:03pmCFormatDriveDialog::~CFormatDriveDialog(void) { if (m_hHook != NULL) { UnhookWindowsHookEx(m_hHook); CFormatDriveDialog::m_hHook = NULL; } }
ReplyAbout a problem
Posted by Legacy on 06/15/2003 12:00amOriginally 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:
#ifndef NOT_USE_PRECOMPILED_HEADER
# include "StdAfx.h"
#else
# define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
# include <afxwin.h> // MFC core and standard components
#endif
What is wrong?(I used VC6)
ReplyAs to the CD
Posted by Legacy on 11/20/2002 12:00amOriginally posted by: ZHEFU ZHANG
Hi, Rino, Thanks for yr good sample.
ReplyDo 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:00amOriginally 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.
-
ReplyFloppy Formatter
Posted by asinha on 03/16/2005 12:47amGood
ReplySimilar to an existing article published elsewhere
Posted by Legacy on 10/25/2002 12:00amOriginally posted by: Ravi Bhavnani
Seems awfully similar to this article:
http://www.codeproject.com/dialog/CFormatDriveDialog.asp.
:)
/ravi
Reply