如何获得硬盘分区数量。(10分)

  • 主题发起人 主题发起人 yunxi126
  • 开始时间 开始时间
Y

yunxi126

Unregistered / Unconfirmed
GUEST, unregistred user!
如题。
C,D,E
则返回3
 
沉了。 自已顶一下。
 
取当前可用驱动器关键词:驱动器
取当前可用驱动器
返回值为一个字符串,形如'ABCD'

function myGetLogicalDrives : String;

var

drives : set of 0..25;

drive : integer;

begin

Result := '';

DWORD( drives ) := Windows.GetLogicalDrives;

for drive := 0 to 25 do

if drive in drives then

Result := Result + Chr( drive + Ord( 'A' ));

end;

*********************

取的有效驱动器

API函数

DWORD GetLogicalDrives(VOID);

DWORD GetLogicalDriveStrings(

DWORD nBufferLength, // size of buffer

LPTSTR lpBuffer // drive strings buffer

);

UINT GetDriveType(

LPCTSTR lpRootPathName // root directory

);

******************

AvailableDrives :dword;

AvailableDrives := GetLogicalDrives;

for i:= 0 to 25 do

if GetBit(AvailableDrives,i+1)=1 then//如果驱动器存在

begin

DrivePath:=Char(Ord('A')+i)+':;

case GetDriveType(pchar(DrivePath)) of

DRIVE_FIXED :....//如果是硬盘

DRIVE_......

end;

很 早的资料了,希望对你有用。
 
接受答案了.
 
后退
顶部