Programalama > DELPHI


Ort. 0
Puan ver:
procedure TForm1.Button1Click(Sender: TObject);
var EMode: Word;
begin
 EMode := SetErrorMode(SEM_FAILCRITICALERRORS);
 try
   if DiskSize(Ord('A')-$40) <> -1 then
     ShowMessage('Disk in drive A: !')
   else
     ShowMessage('No disk in drive A: !');
 finally
   SetErrorMode(EMode);
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var Drive: Byte;
    sFD, sSD : string;
    DFree, DSize : integer;
begin
 Drive:=1;
 DFree:=DiskFree(Drive);
 DSize:=DiskSize(Drive);
 if (DFree <> -1) and (DSize <> -1) then begin
   sFD:='Disk Free: '+IntToStr(DFree div 1024)+' Kb';
   sSD:='Disk Size: '+IntToStr(DSize div 1024)+' Kb';
   ShowMessage(sFD + #13 + sSD);
 end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var VolumeSerialNumber : DWORD;
    MaximumComponentLength : DWORD;
    FileSystemFlags : DWORD;
    SerialNumber : string;
begin
GetVolumeInformation('A:\',
  nil,
  0,
  @VolumeSerialNumber,
  MaximumComponentLength,
  FileSystemFlags,
  nil,
  0);
 SerialNumber:=IntToHex(HiWord(VolumeSerialNumber),4)
               + ' - ' +
               IntToHex(LoWord(VolumeSerialNumber),4);

 ShowMessage(SerialNumber);
end;

function SHFormatDrive(hWnd : HWND;
                       Drive : Word;
                       fmtID : Word;
                       Options : Word) : Longint
stdcall; external 'Shell32.dll' name 'SHFormatDrive';

procedure TForm1.Button4Click(Sender: TObject);
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;
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('Drive is not formatable')
  else
    ShowMessage('Disk has been formatted');
  end;
 except
  ShowMessage('Error occurred!')
 end;
end;



Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.