was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

40 Visitors Online


 
...ein Win32 Laufwerk formatieren?
Autor: Charly
Homepage: http://delphi.charly-online.com
[ Tip ausdrucken ]  

Tip Bewertung (11):  
     



// formating a floppy drive, harddisk, or another drive
// Eine Diskette, Harddisk oder ein anderes Laufwerk formatieren

{
  The SHFormatDrive API provides access to the Shell's format
  dialog box. This allows applications that want to format disks to bring
  up the same dialog box that the Shell uses for disk formatting.
}

const 
  
SHFMT_DRV_A = 0;
  SHFMT_DRV_B = 1;
  SHFMT_ID_DEFAULT = $FFFF;
  SHFMT_OPT_QUICKFORMAT = 0;
  SHFMT_OPT_FULLFORMAT = 1;
  SHFMT_OPT_SYSONLY = 2;
  SHFMT_ERROR = -1;
  SHFMT_CANCEL = -2;
  SHFMT_NOFORMAT = -3;

function SHFormatDrive(hWnd: HWND;
  Drive: Word;
  fmtID: Word;
  Options: Word): Longint
  stdcallexternal 'Shell32.dll' Name 'SHFormatDrive';


procedure TForm1.Button1Click(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
    
ShowMessage('Error Occured!');
  end;
end;


{
  Normally, if a diskette is not in the drive when SHFormatDrive is called,
  the system displays a critical error dialog box that asks the user
  to Abort, Retry, or Ignore.
  You can prevent the system from displaying this dialog box by calling
  the SetErrorMode API with SEM_FAILCRITICALERRORS.
}

var
  
EMode: Word;
begin
  
EMode := SetErrorMode(SEM_FAILCRITICALERRORS);
  // ShFormatDrive Code....
  
SetErrorMode(EMode);
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners