roger_ding
驱动牛犊
驱动牛犊
  • 注册日期2002-06-03
  • 最后登录2008-10-13
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2430回复:18

有谁知道怎样枚举系统的物理硬盘吗?以及这些物理硬盘和那些逻辑盘对应?

楼主#
更多 发布于:2002-07-12 10:47
有那位知道的,请赐教!


[编辑 -  7/13/02 by  roger_ding]
guardee
驱动巨牛
驱动巨牛
  • 注册日期2002-11-08
  • 最后登录2010-05-29
  • 粉丝2
  • 关注1
  • 积分2分
  • 威望34点
  • 贡献值0点
  • 好评度6点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2002-07-12 23:39
在DDK里面有函数可以得到有多少个物理硬盘的啊!至于你说的物理硬盘和逻辑硬盘的对应关系!你的说法可能有误,我的理解是逻辑分区属于那个物理硬盘,也可以通过取设备对象来得到的!你去看看DDK里面的例子吧!在src里面的
NTDDK\\src\\storage\\filters\\diskperf
roger_ding
驱动牛犊
驱动牛犊
  • 注册日期2002-06-03
  • 最后登录2008-10-13
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2002-07-13 11:27
先谢谢你的回答,不过有两点我没说清楚,我想在AP这一层实现它,还有就是要在9x下也能工作,2000下其实就可以用MS的enumdisk来实现,但9x下我不知道该怎么做?
VanCheer
驱动老牛
驱动老牛
  • 注册日期2002-02-21
  • 最后登录2003-08-28
  • 粉丝0
  • 关注0
  • 积分-20分
  • 威望-10点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地板#
发布于:2002-07-13 11:35
先谢谢你的回答,不过有两点我没说清楚,我想在AP这一层实现它,还有就是要在9x下也能工作,2000下其实就可以用MS的enumdisk来实现,但9x下我不知道该怎么做?

GetLogicalDrives可以得到所有的逻辑盘,然后用GetDriveType可以看它是不是硬盘
好好看看File I/O API吧
[img]http://www.driverdevelop.com/forum/upload/VanCheer/2003-03-21_mon.gif[/img][img]http://www.driverdevelop.com/forum/upload/VanCheer/2002-12-07_smallbaby.jpg[/img]
roger_ding
驱动牛犊
驱动牛犊
  • 注册日期2002-06-03
  • 最后登录2008-10-13
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2002-07-13 11:55
那样只能得到逻辑盘,但我想知道系统中有多少物理硬盘以及每个物理硬盘对应哪几个逻辑盘
guardee
驱动巨牛
驱动巨牛
  • 注册日期2002-11-08
  • 最后登录2010-05-29
  • 粉丝2
  • 关注1
  • 积分2分
  • 威望34点
  • 贡献值0点
  • 好评度6点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2002-07-15 10:04
在应用层的话可以用createfile的啊!你去看看该函数的使用吧!具体的我先不告诉你了,因为里面有一些说明,自己再考虑一下就可以解决的了!2K和9x是一样的方法
roger_ding
驱动牛犊
驱动牛犊
  • 注册日期2002-06-03
  • 最后登录2008-10-13
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2002-07-15 15:14
在应用层的话可以用createfile的啊!你去看看该函数的使用吧!具体的我先不告诉你了,因为里面有一些说明,自己再考虑一下就可以解决的了!2K和9x是一样的方法


可有的方法只是针对2000的,9x下应该怎么做呢?
拜托了!如果9x也可以的话我送你40分!
有源码的话可以发到我mail里
mail:roger_ding@yahoo.com.cn
Ares
驱动小牛
驱动小牛
  • 注册日期2001-03-28
  • 最后登录2020-04-09
  • 粉丝0
  • 关注0
  • 积分20分
  • 威望114点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
7楼#
发布于:2002-07-15 15:25
9x下用VWIN32直接访问硬盘
易水
xdjm
驱动中牛
驱动中牛
  • 注册日期2001-04-02
  • 最后登录2024-01-25
  • 粉丝0
  • 关注0
  • 积分34分
  • 威望25点
  • 贡献值0点
  • 好评度3点
  • 原创分0分
  • 专家分0分
  • 社区居民
8楼#
发布于:2002-07-15 16:13
我认为应该通过端口I/O来访问,君不见BIOS怎么检测硬盘的吗~~~
guardee
驱动巨牛
驱动巨牛
  • 注册日期2002-11-08
  • 最后登录2010-05-29
  • 粉丝2
  • 关注1
  • 积分2分
  • 威望34点
  • 贡献值0点
  • 好评度6点
  • 原创分0分
  • 专家分0分
9楼#
发布于:2002-07-15 16:44
唉,你怎么不去看msdn上面的说明啊!
The CreateFile function creates or opens the following objects and returns a handle that can be used to access the object:

Consoles
Communications resources
Directories (open only)
Disk devices (Windows NT/2000 only)
Files
Mailslots
Pipes
HANDLE CreateFile(
  LPCTSTR lpFileName,                         // file name
  DWORD dwDesiredAccess,                      // access mode
  DWORD dwShareMode,                          // share mode
  LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
  DWORD dwCreationDisposition,                // how to create
  DWORD dwFlagsAndAttributes,                 // file attributes
  HANDLE hTemplateFile                        // handle to template file
);
Disk Devices
Volume handles may be opened as noncached at the discretion of the file system, even when the noncached option is not specified with CreateFile. You should assume that all Microsoft file systems open volume handles as noncached. The restrictions on noncached I/O for files apply to volumes as well.

A file system may or may not require buffer alignment even though the data is noncached. However, if the noncached option is specified when opening a volume, buffer alignment is enforced regardless of the file system on the volume. It is recommended on all file systems that you open volume handles as noncached and follow the noncached I/O restrictions.

Windows NT/2000: You can use the CreateFile function to open a disk drive or a partition on a disk drive. The function returns a handle to the disk device; that handle can be used with the DeviceIOControl function. The following requirements must be met in order for such a call to succeed:

The caller must have administrative privileges for the operation to succeed on a hard disk drive.
The lpFileName string should be of the form \\\\.\\PHYSICALDRIVEx to open the hard disk x. Hard disk numbers start at zero. For example:
String Meaning
\\\\.\\PHYSICALDRIVE2 Obtains a handle to the third physical drive on the user\'s computer.


For an example showing how to open a physical drive, see Calling DeviceIoControl on Windows NT/2000.

The lpFileName string should be \\\\.\\x: to open a floppy drive x or a partition x on a hard disk. For example:
String Meaning
\\\\.\\A: Obtains a handle to drive A on the user\'s computer.
\\\\.\\C: Obtains a handle to drive C on the user\'s computer.


There is no trailing backslash in a drive name. The string \"\\\\.\\c:\\\" refers to the root directory of drive C.

On Windows 2000, you can also open a volume by referring to its unique volume name. In this case also, there should be no trailing backslash on the unique volume name.

Note that all I/O buffers should be sector aligned (aligned on addresses in memory that are integer multiples of the volume\'s sector size), even if the disk device is opened without the FILE_FLAG_NO_BUFFERING flag. Depending the disk, this requirement may not be enforced.

Windows 95: This technique does not work for opening a logical drive. In Windows 95, specifying a string in this form causes CreateFile to return an error.

The dwCreationDisposition parameter must have the OPEN_EXISTING value.
When opening a floppy disk or a partition on a hard disk, you must set the FILE_SHARE_WRITE flag in the dwShareMode parameter.
当你需要知道有几个物理硬盘的时候只需要通过一个循环就可以了!对于一般的机器x不会大于4的啊!
roger_ding
驱动牛犊
驱动牛犊
  • 注册日期2002-06-03
  • 最后登录2008-10-13
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
10楼#
发布于:2002-07-15 23:03
可是我上面说的是要9x能工作的,\"\\\\\\\\.\\\\C:\", \"\"\\\\\\\\.\\\\PHYSICALDRIVEx\"在9x不行的! :(
\"Windows 95/98/Me: This technique does not work for opening a logical drive. Specifying a string in this form causes CreateFile to return an error.\"
而且最重要的是要知道某个物理硬盘上有几个逻辑盘,你还有什么更好的方法吗?谢了!
guardee
驱动巨牛
驱动巨牛
  • 注册日期2002-11-08
  • 最后登录2010-05-29
  • 粉丝2
  • 关注1
  • 积分2分
  • 威望34点
  • 贡献值0点
  • 好评度6点
  • 原创分0分
  • 专家分0分
11楼#
发布于:2002-07-16 18:53
\"Windows 95/98/Me: This technique does not work for opening a logical drive. Specifying a string in this form causes CreateFile to return an error.\"
但是可以对物理的硬盘
guardee
驱动巨牛
驱动巨牛
  • 注册日期2002-11-08
  • 最后登录2010-05-29
  • 粉丝2
  • 关注1
  • 积分2分
  • 威望34点
  • 贡献值0点
  • 好评度6点
  • 原创分0分
  • 专家分0分
12楼#
发布于:2002-07-16 18:53
在9x下可以用int13的
roger_ding
驱动牛犊
驱动牛犊
  • 注册日期2002-06-03
  • 最后登录2008-10-13
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
13楼#
发布于:2002-07-17 09:12
HANDLE hDev=CreateFile(\"\\\\\\\\.\\\\PHYSICALDRIVE0\",GENERIC_READ,FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0);
在9x不成功???,那物理硬盘还有什么方法打开呢?
int13怎么调用可以求得物理盘和逻辑盘的对应关系?
ufo_online
驱动牛犊
驱动牛犊
  • 注册日期2002-04-26
  • 最后登录2004-03-26
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
14楼#
发布于:2002-07-18 16:28
可以采用WMI(Windows管理接口)的方法。
SDK\\Samples\\SysMgmt\\WMI\\VC\\下的SimpleClient是用来列举逻辑盘的;WMIDiskPerf我也没看过,不知道是干什么的。
当然,WMI也有列举物理盘的方法,我想,可以先列举出物理盘,再查询与其关联的逻辑盘。
这种方法比较麻烦,但可以得到关于查询对象的所有的信息,比如各逻辑盘的大小、剩余多少空间等等。
zdhe
驱动太牛
驱动太牛
  • 注册日期2001-12-26
  • 最后登录2018-06-02
  • 粉丝0
  • 关注0
  • 积分72362分
  • 威望362260点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
15楼#
发布于:2002-07-19 01:53
CM_Enumerate_Classes_Ex
or
CM_Enumerate_Classes
horsedo
驱动小牛
驱动小牛
  • 注册日期2001-11-29
  • 最后登录2018-05-29
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望10点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
16楼#
发布于:2002-08-07 21:50
[quote]先谢谢你的回答,不过有两点我没说清楚,我想在AP这一层实现它,还有就是要在9x下也能工作,2000下其实就可以用MS的enumdisk来实现,但9x下我不知道该怎么做?

GetLogicalDrives可以得到所有的逻辑盘,然后用GetDriveType可以看它是不是硬盘
好好看看File I/O API吧  [/quote]
这个是应用层的,DDK 中有响应的函数吗?
DRIVER中要知道当前系统中的逻辑盘怎么办呢?
不会还要APP告诉它吧,谢谢
yux008007
驱动牛犊
驱动牛犊
  • 注册日期2003-10-12
  • 最后登录2004-12-17
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望1点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
17楼#
发布于:2004-05-26 10:29
IOCTL_DISK_CONTROLLER_NUMBER可以试试看
Leopard
驱动老牛
驱动老牛
  • 注册日期2001-07-13
  • 最后登录2021-12-15
  • 粉丝0
  • 关注0
  • 积分8分
  • 威望53点
  • 贡献值0点
  • 好评度19点
  • 原创分0分
  • 专家分0分
  • 社区居民
  • 忠实会员
18楼#
发布于:2004-05-26 16:14
IOCTL_DISK_CONTROLLER_NUMBER可以试试看
利害, :cool:
游客

返回顶部