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

如何判斷檔案的來源位置?本機or網路?

答題得分者是:pceyes
goat
高階會員


發表:53
回覆:130
積分:134
註冊:2002-06-03

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-10-14 17:13:13 IP:203.160.xxx.xxx 訂閱
請問有沒有什麼方法可以判斷,我執行的檔案(捷徑),是在本機或是網路磁碟?

因為使用者有可能設定「連線網路磁碟」,所以單純以路徑的起始碼(D:\...L:\...等)可能會誤判。

感謝!
pceyes
尊榮會員


發表:70
回覆:657
積分:1140
註冊:2003-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-10-14 18:09:19 IP:220.141.xxx.xxx 訂閱
在學BCB剛好看到這一段,使用GetDriveType Windows Api
檢查其本機型態,如
DRIVE_FIXED 本機磁碟機
DRIVE_REMOTE (NETWORK)DRIVEER
DRIVE_REMOVABLE 可抽拔磁碟
:
:
Windows 32 Api Help 說明如下:
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.


See Also

GetDiskFreeSpace


有關delphi使用方式可以在網路找一下。
------
努力會更接近成功
pceyes
尊榮會員


發表:70
回覆:657
積分:1140
註冊:2003-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-10-14 18:11:43 IP:220.141.xxx.xxx 訂閱
如何判斷是網路空間上的檔案還是硬碟空間的檔案
http://delphi.ktop.com.tw/board.php?cid=30&fid=69&tid=60538
------
努力會更接近成功
goat
高階會員


發表:53
回覆:130
積分:134
註冊:2002-06-03

發送簡訊給我
#4 引用回覆 回覆 發表時間:2008-10-15 10:31:01 IP:203.160.xxx.xxx 訂閱
感謝pceyes,這正是我需要的,3Q。

===================引 用 pceyes 文 章===================
如何判斷是網路空間上的檔案還是硬碟空間的檔案
http://delphi.ktop.com.tw/board.php?cid=30&fid=69&tid=60538

系統時間:2024-04-20 14:09:14
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!