取当前可用驱动器
我想获得当前机器,可用的盘符急啊急  先回复的给分了啊高手们

解决方案 »

  1.   

    我给你一段代码吧前两天刚搞定这个问题返回值为一个字符串,形如'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;
          end;
      

  2.   

    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;  
      

  3.   

    AHA楼主,快给分。。我快没分提问了。。
      

  4.   

    AHA楼主,快给分。。我快没分提问了。。??? 给你的分又不是能够用来提问的