Windows中的最大驱动器数量? [英] Maximum number of drives in windows?

查看:236
本文介绍了Windows中的最大驱动器数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以编程方式在Windows中找出可用的磁盘空间。为此,我需要首先获取可用驱动器的列表,然后检查其中哪些是本地驱动器,然后查询每个本地驱动器上的可用字节。

I'm trying to figure out the available disk space programmatically in windows. For this, I need to first get a list of the available drives, then check which of those are local drives and then query the available bytes on each local drive.

I在第一部分有些卡住了,API提供了两个功能:

I'm a bit stuck on the first part, where the API presents two functions:


  1. GetLogicalDrives http://msdn.microsoft.com/ zh-cn / library / aa364972(VS.85).aspx ),该操作会为您提供一个DWORD,并设置了位(如果存在驱动器A,则为0;如果存在驱动器B,则为1,等等)

  2. GetLogicalDriveStrings http://msdn.microsoft.com/en-us/library/aa364975(VS.85).aspx ),它为您提供了实际的字符串。

  1. GetLogicalDrives (http://msdn.microsoft.com/en-us/library/aa364972(VS.85).aspx) which gives you a DWORD with the bits set (bit 0 if drive A is present, bit 1 if drive B etc)
  2. GetLogicalDriveStrings (http://msdn.microsoft.com/en-us/library/aa364975(VS.85).aspx) which gives you the actual strings.

现在,尽管稍后我将使用字符串,但我更喜欢使用第一个选项进行查询。但是,在我的系统上,DWORD的类型定义为无符号长,即4个字节,而驱动器字母仅在A-Z范围内(26个-我认为-字符)。显然,一个人可以在其系统上定义26个以上的驱动器(但是不太可能这样做)-因此我想知道这些驱动器是否有任何约定。有人可以指出我的资源吗?

Now, although I'll be using strings later on, I'd prefer using the first option for querying. However, on my system a DWORD is typedef-ed to "unsigned long", which is 4 bytes, whereas drive letters only range A-Z (26 - i think - characters). Obviously, one can define more than 26 drives on their system (however unlikely they are to do so) - so I was wondering if there was any convention for those drives. Can someone point me to a resource on this?

谢谢。

推荐答案


  1. DWORD始终为4个字节,与系统无关(这是Win32类型)。

  1. DWORD is always 4 bytes, regardless of the system (it's a Win32 type).

在Windows中,驱动器字母为26。因为英文字母只有26个字母:)。但是,Windows允许两种方式装载卷:

The maximum for drive letters in Windows is 26. Because English alphabet has only 26 letters :). However, Windows allows two ways to mount a volume:


  • 到驱动器号

  • 到驱动器号目录(在NTFS卷上)。
    您可以将一个卷装载到多个位置(但最多只能装载一个驱动器号,即IIRC)。 控制面板->管理工具->计算机管理->磁盘管理提供了用于此任务的GUI。

  • to a drive letter
  • to a directory (on an NTFS volume). You can mount one volume to multiple locations (but no more than one drive letter, IIRC). A GUI for this task is presented by Control Panel -> Administrative Tools -> Computer Management -> Disk Management.

如果您想拥有26个以上的驱动器,并且其他驱动器被重定向到已经处于活动状态的驱动器,并且可以正常运行,大多数程序,则可以使用以下方法分配更多的代码(警告它们甚至不会显示在文件浏览器中):

If you want to have more than 26 drives with the additional drives being redirects to already active drives and are okay with them not working properly in most programs, then you can assign more with the following method (be warned they won't even show up in the file explorer):

subst ♪: C:\Temp\
cd /D ♪:\

并删除它们(也不会通过重新启动保留):

and to delete them (also they aren't preserved through restarts):

subst /D ♪:

您可以按照本文

这篇关于Windows中的最大驱动器数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆