Ver Mensaje Individual
  #6  
Antiguo 22-11-2017
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.039
Reputación: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
¿Lo has copiado bien?, porque yo he hecho un simple "copia->pega" y funciona perfectamente.
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    bt1: TButton;
    procedure bt1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function DiskInDrive(Drive: Char): Boolean;
  // Disk can be a floppy, CD-ROM,...
var
  ErrorMode: Word;
begin
  { make it upper case }
  if Drive in ['a'..'z'] then Dec(Drive, $20);
  { make sure it's a letter }
  if not (Drive in ['A'..'Z']) then
    raise EConvertError.Create('Not a valid drive ID');
  { turn off critical errors }
  ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
  try
    { drive 1 = a, 2 = b, 3 = c, etc. }
    if DiskSize(Ord(Drive) - $40) = -1 then
      Result := False
    else
      Result := True;
  finally
    { Restore old error mode }
    SetErrorMode(ErrorMode);
  end;
end;

procedure TForm1.bt1Click(Sender: TObject);
begin
  if DiskInDrive('a') = False then
    ShowMessage('Drive not ready');
end;

end.
Responder Con Cita