Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Formatting a drive under Win32


How can I format a drive under Win32?   

    You can use the ShellAPI funciton ShFormatDrive(). Example:

    const SHFMT_DRV_A = 0;
    const SHFMT_DRV_B =  ;
    const SHFMT_ID_DEFAULT = $FFFF;
    const SHFMT_OPT_QUICKFORMAT = 0;
    const SHFMT_OPT_FULLFORMAT =  ;
    const SHFMT_OPT_SYSONLY = 2;
    const SHFMT_ERROR = - ;
    const SHFMT_CANCEL = -2;
    const SHFMT_NOFORMAT = -3;
    function SHFormatDrive(hWnd : HWND;
                           Drive : Word;
                           fmtID : Word;
                           Options : Word) : Longint
       stdcall; external 'Shell32.dll' name 'SHFormatDrive';
    procedure TForm .Button Click(Sender: TObject);
    var
      FmtRes : longint;
    begin
      try
        FmtRes:= ShFormatDrive(Handle,
                               SHFMT_DRV_A,
                               SHFMT_ID_DEFAULT,
                               SHFMT_OPT_QUICKFORMAT);
        case FmtRes  of
         SHFMT_ERROR : ShowMessage('Error formatting the drive');
         SHFMT_CANCEL : 
           ShowMessage('User canceled formatting the drive');
         SHFMT_NOFORMAT : ShowMessage('No Format')
        else
         ShowMessage('Disk has been formatted');
        end;
      except
      end;
    end;
    

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use