¿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
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function DiskInDrive(Drive: Char): Boolean;
var
ErrorMode: Word;
begin
if Drive in ['a'..'z'] then Dec(Drive, $20);
if not (Drive in ['A'..'Z']) then
raise EConvertError.Create('Not a valid drive ID');
ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
try
if DiskSize(Ord(Drive) - $40) = -1 then
Result := False
else
Result := True;
finally
SetErrorMode(ErrorMode);
end;
end;
procedure TForm1.bt1Click(Sender: TObject);
begin
if DiskInDrive('a') = False then
ShowMessage('Drive not ready');
end;
end.