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

偵測硬碟存不存在

尚未結案
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-01-27 17:59:00 IP:61.222.xxx.xxx 未訂閱
我想寫個偵測硬碟存不存在  
for(ch='C';ch<='D';ch  )
}
 
可是不知道用那個API寫的出來 ~我還在學習狀態希望多多向您學習~
RaynorPao
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-01-27 23:41:16 IP:61.221.xxx.xxx 未訂閱
引言: 我想寫個偵測硬碟存不存在
for(ch='C';ch<='D';ch++)
}
 
可是不知道用那個API寫的出來 ~我還在學習狀態希望多多向您學習~
kraen4468 你好: 請參考以下的做法 < class="code"> for(char sz='C'; sz<='G'; sz++) { AnsiString szPath=(AnsiString)sz+":\\"; if(DirectoryExists(szPath)) { ShowMessage(szPath+" exist!"); } else { ShowMessage(szPath+" not exist!"); } } -- Enjoy Researching & Developing --
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
aquarius
資深會員


發表:3
回覆:347
積分:330
註冊:2003-05-21

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-01-28 09:48:56 IP:211.23.xxx.xxx 未訂閱
引言: 我想寫個偵測硬碟存不存在
for(ch='C';ch<='D';ch  )
}
 
可是不知道用那個API寫的出來 ~我還在學習狀態希望多多向您學習~
請參考 GetDriveType 這個 API 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 ); Parameters lpRootPathName Points to a null-terminated string that specifies the root directory of the disk to return information about. If lpRootPathName is NULL, the function uses the root of the current directory. Return Values The return value specifies the type of drive. It can be one of the following values: Value Meaning 0 The drive type cannot be determined. 1 The root directory does not exist. DRIVE_REMOVABLE The drive can be removed from the drive. DRIVE_FIXED The disk cannot be removed from the drive. DRIVE_REMOTE The drive is a remote (network) drive. DRIVE_CDROM The drive is a CD-ROM drive. DRIVE_RAMDISK The drive is a RAM disk. ...Aquarius
------
水瓶男的blog: http://791909.blogspot.com
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-01-28 16:20:14 IP:61.218.xxx.xxx 未訂閱
kraen4468: 試著修改下面的範例:就是您要的答案:)    
#include 
#include     void __fastcall TForm1::Button2Click(TObject *Sender)
{        LPTSTR lpBuffer  ;
    DWORD dwDeviceCnt;
    dwDeviceCnt =  GetLogicalDriveStrings( 0,    lpBuffer );  //讀到字串的大小        if(dwDeviceCnt)
    {
        char *buf = new char [dwDeviceCnt];
        GetLogicalDriveStrings(dwDeviceCnt,  buf  );
        std::vector vStrDevice;
        for(DWORD idx =0 ;idxLines->Add(vStrDevice[idx]   " DRIVE_UNKNOWN");
                    break;
                case  DRIVE_NO_ROOT_DIR:
                    Memo2->Lines->Add(vStrDevice[idx]   " DRIVE_NO_ROOT_DIR");
                    break;
                case  DRIVE_REMOVABLE  :
                    Memo2->Lines->Add(vStrDevice[idx]   " DRIVE_REMOVABLE");
                                                                            
                    break;
                case  DRIVE_FIXED      :
                    Memo2->Lines->Add(vStrDevice[idx]   " DRIVE_FIXED");
                    break;
                case  DRIVE_REMOTE     :
                    Memo2->Lines->Add(vStrDevice[idx]   " DRIVE_REMOTE");
                    break;
                case  DRIVE_CDROM      :
                    Memo2->Lines->Add(vStrDevice[idx]   " DRIVE_CDROM");
                    break;
                case  DRIVE_RAMDISK    :
                    Memo2->Lines->Add(vStrDevice[idx]   " DRIVE_RAMDISK");
                    break;
            }
        }
        delete buf;
    }
}
/*生活是一種藝術,用心生活才能享受生活*/
發表人 - axsoft 於 2004/01/28 16:22:08
系統時間:2024-05-02 6:24:27
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!