如何得知总共有多少个驱动器? (5分)

  • 主题发起人 主题发起人 carem1
  • 开始时间 开始时间
C

carem1

Unregistered / Unconfirmed
GUEST, unregistred user!
就是打开我的电脑之后,看到的那些 a:/ c:/ d:/ e:/ f:/ 等等<br>我怎么知道总共有多少个??那个是软驱,那个是光驱?
 
[:)] 打开电脑后在“我的电脑”中可以看到。a: 和 b: 是软驱;如果系统不出错和没有用着虚拟光驱之类的软件的话,一般来说最后一个驱动器 x:(x代表c到z的任意字母)是光驱,z以前的驱动器是硬盘.
 
能说些有用的么??我说的是用api实现。<br>
 
建议你去查API大全
 
DWORD GetLogicalDrives(VOID);<br><br>DWORD GetLogicalDriveStrings(<br>&nbsp; &nbsp; DWORD nBufferLength, // size of buffer <br>&nbsp; &nbsp; LPTSTR lpBuffer // address of buffer for drive strings <br>&nbsp; &nbsp;);<br><br>UINT GetDriveType(<br>&nbsp; &nbsp; LPCTSTR lpRootPathName // address of root path <br>&nbsp; &nbsp;);<br>
 
procedure TScandisk.Execute;<br>var &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;name: CHAR;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;drvname: string;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CDtype:UINT;<br><br>begin<br>&nbsp; &nbsp; &nbsp; &nbsp;GetMem(volname, 255);<br>&nbsp; &nbsp; &nbsp; &nbsp;GetMem(filesysname, 100);<br>&nbsp; &nbsp; &nbsp; &nbsp;for name :='D' to 'Z' &nbsp;do//&amp;Ntilde;&amp;shy;&amp;raquo;·&amp;frac14;ì&amp;sup2;&amp;acirc;A&amp;iexcl;&amp;laquo;Z<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;drvname := name + ':';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CDtype := GetDriveType(PCHAR(@drvname[1])); //&amp;raquo;&amp;ntilde;&amp;micro;&amp;Atilde;&amp;acute;&amp;Aring;&amp;Aring;&amp;Igrave;&amp;Agrave;à&amp;ETH;&amp;Iacute;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (CDtype = DRIVE_FIXED) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br><br>.... &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp;FreeMem(volname);<br>&nbsp; &nbsp; &nbsp; &nbsp;FreeMem(filesysname)<br><br>end;<br>//other type <br>&nbsp; DRIVE_UNKNOWN = 0;<br>&nbsp; {$EXTERNALSYM DRIVE_UNKNOWN}<br>&nbsp; DRIVE_NO_ROOT_DIR = 1;<br>&nbsp; {$EXTERNALSYM DRIVE_NO_ROOT_DIR}<br>&nbsp; DRIVE_REMOVABLE = 2;<br>&nbsp; {$EXTERNALSYM DRIVE_REMOVABLE}<br>&nbsp; DRIVE_FIXED = 3;<br>&nbsp; {$EXTERNALSYM DRIVE_FIXED}<br>&nbsp; DRIVE_REMOTE = 4;<br>&nbsp; {$EXTERNALSYM DRIVE_REMOTE}<br>&nbsp; DRIVE_CDROM = 5;<br>&nbsp; {$EXTERNALSYM DRIVE_CDROM}<br>&nbsp; DRIVE_RAMDISK = 6;<br>&nbsp; {$EXTERNALSYM DRIVE_RAMDISK}<br><br>
 
来晚了。 呵呵。
 
volname,filesysname 什么东西??<br>//&amp;Ntilde;&amp;shy;&amp;raquo;·&amp;frac14;ì&amp;sup2;&amp;acirc;A&amp;iexcl;&amp;laquo;Z<br>又是什么东西??能不能清楚一点阿?<br><br>
 
精通Delphi是我的梦想,本QQ群只用于技术交流,互通有无,有求必应,与同道者同勉!<br>Delphi群---2986125 &nbsp;
 
volname,filesysname: PCHAR;<br><br>乱码1:遍历所有驱动器<br>乱码2:得到磁盘类型<br>
 
后退
顶部