線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1175
推到 Plurk!
推到 Facebook!

如何取得軟碟機的狀態?

 
領航天使
站長


發表:12216
回覆:4186
積分:4084
註冊:2001-07-25

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-06-23 22:32:54 IP:192.168.xxx.xxx 未訂閱
如何取得軟碟機的狀態?
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;    type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;    var
  Form1: TForm1;    implementation    {$R *.DFM}
type
  TDriveState = (DSNODISK, DSUNFORMATTEDDISK, DSEMPTYDISK, DSDISK_WITHFILES);    function DriveState (driveletter: Char) : TDriveState;
var
  mask: String[6];
  sRec: TSearchRec;
  oldMode: Cardinal;
  retcode: Integer;
begin
  oldMode:= SetErrorMode(SEM_FAILCRITICALERRORS);
  mask:= '?:\*.*';
  mask[1] := driveletter;
  {$I-}
  retcode := FindFirst (mask, faAnyfile, SRec);
  FindClose(SRec);
  {$I }
  case retcode of
    0: Result := DSDISK_WITHFILES; { at least one file was found  }
    -18: Result := DSEMPTYDISK;    { no files, but disk is ok     }
    -21, -3: Result := DSNODISK;   { DOS ERRORNOTREADY in WinNT,
                                       ERRORPATH_NOTFOUND in 3.1  }
  else
     Result := DSUNFORMATTEDDISK;   { unformatted disk in drive    }
  end;
  SetErrorMode(oldMode);
end; { DriveState }    procedure TForm1.Button1Click(Sender: TObject);
var status:TDriveState;
begin
  status:=DriveState('A');
  if status=DSNODISK then showmessage('無磁片')
  else
  if status=DSUNFORMATTEDDISK then showmessage('磁片未格式化')
  else
  if status=DSEMPTYDISK then showmessage('空白磁片')
  else
  if status=DSDISK_WITHFILES then showmessage('磁片內有資料')
end;    end.
~~~Delphi K.Top討論區站長~~~
------
~~~Delphi K.Top討論區站長~~~
附加檔案:00018990_unit1.pas
系統時間:2024-11-23 5:45:21
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!