怎么遍历硬盘上的驱动器?不用控件

解决方案 »

  1.   

    这是我以前的一个function,应该是得到硬盘的驱动器号
    你是要这个么??还是别的?
    function TForm3.LoadDrives:string;                         // read server logical drives
    var
      Drv:array [0..MAX_PATH] of Char;
      buf:Cardinal;
      Drives:string;
      i:integer;
    begin
      Drives:='';
      Result:='';
      buf:=MAX_PATH;
      GetLogicalDriveStrings(buf,Drv);        //DRV&micro;&Atilde;&micro;&frac12;&Egrave;&ccedil;&pound;&ordm;c:\<null>d:\<null><null>    &frac14;&ucirc;msdn
      for i:=0 to MAX_PATH do
      begin
        if (Drv[i]=#0) and (Drv[i+1]=#0) then exit;     //&Oacute;&Atilde;&Oacute;&Uacute;×&icirc;&ordm;ó&frac12;á&Ecirc;&oslash;×&Ouml;·&ucirc;&acute;&reg;
        if Drv[i]<>#0 then Drives:=Drives+Drv[i]
        else begin
          Result:=Result+Drives;
          Drives:='';
        end;
      end;
    end;