如何列举出全部磁盘, 全文检索不能用,只好再发帖子了.:((10分)

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

yhl1118

Unregistered / Unconfirmed
GUEST, unregistred user!
不要用控件
 
呵呵,从csdn上找到的<br><br>function LoadDrives:string; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // read server logical drives<br>var<br>&nbsp; Drv:array [0..MAX_PATH] of Char;<br>&nbsp; buf:Cardinal;<br>&nbsp; Drives:string;<br>&nbsp; i:integer;<br>begin<br>&nbsp; Drives:='';<br>&nbsp; Result:='';<br>&nbsp; buf:=MAX_PATH;<br>&nbsp; GetLogicalDriveStrings(buf,Drv); &nbsp; &nbsp; &nbsp; &nbsp;//DRV&amp;micro;&amp;Atilde;&amp;micro;&amp;frac12;&amp;Egrave;&amp;ccedil;&amp;pound;&amp;ordm;c:/&lt;null&gt;d:/&lt;null&gt;&lt;null&gt; &nbsp; &nbsp;&amp;frac14;&amp;ucirc;msdn<br>&nbsp; for i:=0 to MAX_PATH do<br>&nbsp; begin<br>&nbsp; &nbsp; if (Drv=#0) and (Drv[i+1]=#0) then exit; &nbsp; &nbsp; //&amp;Oacute;&amp;Atilde;&amp;Oacute;&amp;Uacute;×&amp;icirc;&amp;ordm;ó&amp;frac12;á&amp;Ecirc;&amp;oslash;×&amp;Ouml;·&amp;ucirc;&amp;acute;&amp;reg;<br>&nbsp; &nbsp; if Drv&lt;&gt;#0 then Drives:=Drives+Drv<br>&nbsp; &nbsp; else begin<br>&nbsp; &nbsp; &nbsp; Result:=Result+Drives;<br>&nbsp; &nbsp; &nbsp; Drives:='';<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;
 
用GetDriveType可以知道盘的类型<br>var<br>&nbsp; i:integer<br>&nbsp; Drive:char;<br>&nbsp; DriveType:integer;<br>&nbsp; Display:string;<br>begin<br>&nbsp; for i:=1 to 26 do<br>&nbsp; begin<br>&nbsp; &nbsp; Drive:=chr(64+i);<br>&nbsp; &nbsp; DriveType:=GetDriveType(pchar(Drive+':/'));<br>{0 The drive type cannot be determined.<br>1 The root directory does not exist.<br>DRIVE_REMOVABLE The drive can be removed from the drive. &nbsp; &nbsp; &nbsp;2<br>DRIVE_FIXED The disk cannot be removed from the drive. &nbsp; &nbsp;3<br>DRIVE_REMOTE The drive is a remote (network) drive. &nbsp; &nbsp; &nbsp; &nbsp;4<br>DRIVE_CDROM The drive is a CD-ROM drive. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5<br>DRIVE_RAMDISK The drive is a RAM disk. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;6<br>&nbsp;}<br>&nbsp; &nbsp; Display:='驱动器'+Drive+':';<br>&nbsp; &nbsp; case DriveType of<br>&nbsp; &nbsp; &nbsp; 0:Display:=Display+'不存在';<br>&nbsp; &nbsp; &nbsp; 1:Display:=Display+'找不到根目录';<br>&nbsp; &nbsp; &nbsp; 2:Display:=Display+'可移动盘';<br>&nbsp; &nbsp; &nbsp; 3:Display:=Display+'硬盘';<br>&nbsp; &nbsp; &nbsp; 4:Display:=Display+'网络盘';<br>&nbsp; &nbsp; &nbsp; 5:Display:=Display+'光驱';<br>&nbsp; &nbsp; &nbsp; 6:Display:=Display+'虚拟盘';<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; Memo1.Lines.Add(Display);<br>&nbsp; end;<br>end;<br>
 
建立一个从‘A’到‘Z’循环,循环中调用GetDriveType()<br><br>和楼上的差不多
 
var<br>drives : set of 0..25;<br>drive : integer;<br>DriveType:word;<br><br>begin<br>Result := '';<br>DWORD( drives ) := Windows.GetLogicalDrives;<br>for drive := 2 to 25 do<br>if drive in drives then<br>begin<br>DriveType:=GetDriveType(pchar(chr(drive+$41)+':/'));<br>case DriveType of<br>DRIVE_UNKNOWN:<br>DRIVE_NO_ROOT_DIR:<br>DRIVE_REMOVABLE:<br>DRIVE_FIXED:<br>DRIVE_REMOTE:<br>DRIVE_CDROM:<br>DRIVE_RAMDISK:<br>end;<br><br><br>end;
 
全文检索<br>http://24.103.53.13/index.html
 
for i:=0 to 23 do begin<br>&nbsp; &nbsp; &nbsp; s := Chr(65+i)+':/';<br>&nbsp; &nbsp; if DirectoryExists(s)=true then<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>end;<br>在uses 里加入FileCtrl<br>
 
多谢各位,分不多,随便分了,抱歉
 
后退
顶部