• 大小: 59KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-05
  • 语言: 其他
  • 标签: 硬盘信息  

资源简介

VC下获取硬盘信息,支持IDE,SCSI. 运行后如下: Physical drive 0 ---- Model number: Hitachi HTS541280H9AT00 Serial number: HP0C00BFGV8NJAGV8NJA Firmware reversion: HP3OA23C ATA/ATAPI versions supported: , ATA-2, ATA-3, ATA/ATAPI-4, ATA/ATAPI-5, ATA/ATAPI-6 Buffer size on drive: 7709184 bytes Cylinders: 16383 Heads: 16 Sectors per track: 63 Total sectors: 156301488 Total size: 80026361856 bytes Addressable cylinders in CHS translation: 16383 Addressable heads in CHS translation: 16 Addressable sectors per track in CHS translation: 63 Addressable sectors in CHS translation: 16514064 Addressable size in CHS translation: 8455200768 bytes Advanced PIO modes supported: 3 DMA supported: Yes LBA supported: Yes IORDY supported: Yes IORDY may be disabled: Yes Overlap operation supported: No Command queuing supported: No Interleaved DMA supported: No Ultra DMA mode 0 (16.7Mb/s) supported: Yes Ultra DMA mode 1 (25Mb/s) supported: Yes Ultra DMA mode 2 (33Mb/s) supported: Yes Ultra DMA mode 3 (44Mb/s) supported: Yes Ultra DMA mode 4 (66Mb/s) supported: Yes Ultra DMA mode 5 (100Mb/s) supported: Yes Ultra DMA mode 6 (133Mb/s) supported: No Ultra DMA mode 7 (166Mb/s) supported: No Ultra DMA mode currently selected: 5

资源截图

代码片段和文件信息

#include “stdafx.h“
#include “GetIdeDiskInfo.h“

// 打开设备
// filename: 设备的“文件名”
HANDLE OpenDevice(LPCTSTR filename)
{
HANDLE hDevice;

// 打开设备
hDevice= ::CreateFile(filename // 文件名
GENERIC_READ | GENERIC_WRITE // 读写方式
FILE_SHARE_READ | FILE_SHARE_WRITE // 共享方式
NULL // 默认的安全描述符
OPEN_EXISTING // 创建方式
0 // 不需设置文件属性
NULL); // 不需参照模板文件

return hDevice;
}

// 向驱动发“IDENTIFY DEVICE”命令,获得设备信息
// hDevice: 设备句柄
// pIdInfo:  设备信息结构指针
BOOL IdentifyDevice(HANDLE hDevice PIDINFO pIdInfo)
{
PSENDCMDINPARAMS pSCIP; // 输入数据结构指针
PSENDCMDOUTPARAMS pSCOP; // 输出数据结构指针
DWORD dwOutBytes; // IOCTL输出数据长度
BOOL bResult; // IOCTL返回值

// 申请输入/输出数据结构空间
    pSCIP = (PSENDCMDINPARAMS)::GlobalAlloc(LMEM_ZEROINIT sizeof(SENDCMDINPARAMS)-1);
    pSCOP = (PSENDCMDOUTPARAMS)::GlobalAlloc(LMEM_ZEROINIT sizeof(SENDCMDOUTPARAMS)+sizeof(IDINFO)-1);

// 指定ATA/ATAPI命令的寄存器值
// pSCIP->irDriveRegs.bFeaturesReg = 0;
// pSCIP->irDriveRegs.bSectorCountReg = 0;
// pSCIP->irDriveRegs.bSectorNumberReg = 0;
// pSCIP->irDriveRegs.bCylLowReg = 0;
// pSCIP->irDriveRegs.bCylHighReg = 0;
// pSCIP->irDriveRegs.bDriveHeadReg = 0;
pSCIP->irDriveRegs.bCommandReg = IDE_ATA_IDENTIFY;

// 指定输入/输出数据缓冲区大小
pSCIP->cBufferSize = 0;
pSCOP->cBufferSize = sizeof(IDINFO);

// IDENTIFY DEVICE
bResult = ::DeviceIoControl(hDevice // 设备句柄
DFP_RECEIVE_DRIVE_DATA // 指定IOCTL
pSCIP sizeof(SENDCMDINPARAMS) - 1 // 输入数据缓冲区
pSCOP sizeof(SENDCMDOUTPARAMS) + sizeof(IDINFO) - 1 // 输出数据缓冲区
&dwOutBytes // 输出数据长度
(LPOVERLAPPED)NULL); // 用同步I/O

// 复制设备参数结构
::memcpy(pIdInfo pSCOP->bBuffer sizeof(IDINFO));

// 释放输入/输出数据空间
::GlobalFree(pSCOP);
::GlobalFree(pSCIP);

return bResult;
}

// 向SCSI MINI-PORT驱动发“IDENTIFY PACKET DEVICE”命令,获得设备信息
// hDevice: 设备句柄
// pIdInfo:  设备信息结构指针
BOOL IdentifyDeviceAsScsi(HANDLE hDevice int nDrive PIDINFO pIdInfo)
{
PSENDCMDINPARAMS pSCIP; // 输入数据结构指针
PSENDCMDOUTPARAMS pSCOP; // 输出数据结构指针
PSRB_IO_CONTROL pSRBIO; // SCSI输入输出数据结构指针
DWORD dwOutBytes; // IOCTL输出数据长度
BOOL bResult; // IOCTL返回值

// 申请输入/输出数据结构空间
    pSRBIO = (PSRB_IO_CONTROL)::GlobalAlloc(LMEM_ZEROINIT sizeof(SRB_IO_CONTROL)+sizeof(SENDCMDOUTPARAMS)+sizeof(IDINFO)-1);
    pSCIP = (PSENDCMDINPARAMS)((char *)pSRBIO+sizeof(SRB_IO_CONTROL));
    pSCOP = (PSENDCMDOUTPARAMS)((char *)pSRBIO+sizeof(SRB_IO_CONTROL));

// 填充输入/输出数据
pSRBIO->HeaderLength = sizeof(SRB_IO_CONTROL);
pSRBIO->Timeout = 10000;
pSRBIO->Length = sizeof(SENDCMDOUTPARAMS)+sizeof(IDINFO)-1;
pSRBIO->ControlCode = IOCTL_SCSI_MINIPORT_IDENTIFY;
    ::strncpy ((char *)pSRBIO->Signature “SCSIDISK“ 8);

// 指定ATA/ATAPI命令的寄存器值
// pSCIP->irDriveRegs.bFeaturesReg = 0;
// pSCIP->irDriveRegs.bSectorCountReg = 0;
// pSCIP->irDriveRegs.bSectorNumberReg = 0;
// pSCIP->irDriveRegs.bCylLowReg = 0;
// pSCIP->irDriveRegs.bCylHighReg = 0;
// pSCIP->ir

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2007-08-31 23:05  IdeDiskInfo\Debug\
     文件        6122  2003-02-24 11:12  IdeDiskInfo\GetIdeDiskInfo.cpp
     文件        7697  2003-02-24 10:58  IdeDiskInfo\GetIdeDiskInfo.h
     文件       29396  2007-08-15 19:45  IdeDiskInfo\IdeDiskInfo.aps
     文件        4300  2003-02-21 10:21  IdeDiskInfo\IdeDiskInfo.cpp
     文件        4800  2003-02-21 11:18  IdeDiskInfo\IdeDiskInfo.dsp
     文件         545  2003-02-21 10:21  IdeDiskInfo\IdeDiskInfo.dsw
     文件        1411  2003-02-21 10:21  IdeDiskInfo\IdeDiskInfo.h
     文件       74752  2007-08-23 14:57  IdeDiskInfo\IdeDiskInfo.ncb
     文件       54784  2007-08-23 14:57  IdeDiskInfo\IdeDiskInfo.opt
     文件        1851  2007-08-23 14:57  IdeDiskInfo\IdeDiskInfo.plg
     文件       11972  2003-02-24 10:15  IdeDiskInfo\IdeDiskInfo.rc
     文件        1918  2003-02-21 10:21  IdeDiskInfo\IdeDiskInfoDoc.cpp
     文件        1530  2003-02-21 10:21  IdeDiskInfo\IdeDiskInfoDoc.h
     文件        9498  2003-02-24 10:12  IdeDiskInfo\IdeDiskInfoView.cpp
     文件        1992  2003-02-24 10:08  IdeDiskInfo\IdeDiskInfoView.h
     文件        2512  2003-02-21 10:21  IdeDiskInfo\MainFrm.cpp
     文件        1581  2003-02-21 10:21  IdeDiskInfo\MainFrm.h
     文件        4431  2003-02-21 10:21  IdeDiskInfo\ReadMe.txt
     目录           0  2007-08-23 14:57  IdeDiskInfo\Release\
     文件       40960  2007-08-23 14:57  IdeDiskInfo\Release\IdeDiskInfo.exe
     目录           0  2007-04-14 18:14  IdeDiskInfo\res\
     文件        1078  2003-02-21 10:21  IdeDiskInfo\res\IdeDiskInfo.ico
     文件         403  2003-02-21 10:21  IdeDiskInfo\res\IdeDiskInfo.rc2
     文件        1078  2003-02-21 10:21  IdeDiskInfo\res\IdeDiskInfoDoc.ico
     文件        1318  2003-02-21 10:24  IdeDiskInfo\res\Toolbar.bmp
     文件         692  2003-02-21 10:24  IdeDiskInfo\Resource.h
     文件         213  2003-02-21 10:21  IdeDiskInfo\StdAfx.cpp
     文件        1054  2003-02-21 10:21  IdeDiskInfo\StdAfx.h
     目录           0  2007-08-23 14:57  IdeDiskInfo\

评论

共有 条评论

相关资源