全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1140
推到 Plurk!
推到 Facebook!

怎样知道指定的盘符是否是可移动硬盘,或者怎样检测是否插入了

答題得分者是:malanlk
cxg
中階會員


發表:116
回覆:192
積分:76
註冊:2004-02-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-12-07 17:49:50 IP:222.35.xxx.xxx 未訂閱
怎样知道指定的盘符是否是可移动硬盘,或者怎样检测是否插入了可移动硬盘。
jow
尊榮會員


發表:66
回覆:751
積分:1253
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-12-08 14:13:56 IP:220.130.xxx.xxx 未訂閱
The GetLogicalDriveStrings function fills a buffer with strings that specify valid drives in the system.     DWORD GetLogicalDriveStrings(        DWORD nBufferLength,        // size of buffer 
    LPTSTR lpBuffer         // address of buffer for drive strings 
   );    The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.     UINT GetDriveType(        LPCTSTR lpRootPathName         // address of root path 
   );    
cxg
中階會員


發表:116
回覆:192
積分:76
註冊:2004-02-12

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-12-09 17:07:23 IP:222.35.xxx.xxx 未訂閱
我测试时GetLogicalDriveStrings函数只得到了软驱。没有我的移动硬盘,不知道为什么。
malanlk
尊榮會員


發表:20
回覆:694
積分:577
註冊:2004-04-19

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-12-11 15:24:00 IP:210.68.xxx.xxx 未訂閱
我這都可以看得到
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Variants, 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}    function GetLogicalDisks: string;
var
  i,n :integer;
  buf :pchar;
begin
  buf:=stralloc(255);
  n:=GetLogicalDriveStrings(255,buf);
  Result:='';
  for i:=0 to n do
    if buf[i]<>#0 then begin
      if (ord(buf[i]) in [$41..$5a]) or (ord(buf[i]) in [$61..$7a]) then
        Result:=Result upcase(buf[i])
    end else
      if buf[i 1]=#0 then
        break;
  strdispose(buf);
end;    procedure TForm1.Button1Click(Sender: TObject);
var
  s: String;
begin
// Logical devices
  s:=GetLogicalDisks;
  showmessage(s);
end;    end.
cxg
中階會員


發表:116
回覆:192
積分:76
註冊:2004-02-12

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-12-12 13:39:08 IP:222.35.xxx.xxx 未訂閱
谢谢两位大大。
系統時間:2024-05-17 14:15:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!