GetHardSoftInfo.h
资源名称:Client.rar [点击查看]
上传用户:szjkjd
上传日期:2022-06-27
资源大小:8968k
文件大小:7k
源码类别:
浏览器
开发平台:
Visual C++
- /*! @GetHardSoftInfo.h
- *******************************************************************************
- <PRE>
- 模块名 : 获得计算机的硬件信息
- 文件名 : GetHardSoftInfo.h
- 相关文件 : GetHardSoftInfo.cpp
- 文件实现功能 : 获得计算机的硬件信息
- 作者 : 王小静
- 版本 : 1.0
- --------------------------------------------------------------------------------
- 备注 : 该类引于第三方文件
- --------------------------------------------------------------------------------
- 修改记录 :
- 日 期 版本 修改人 修改内容
- 2010/02/08 1.0 王小静 创建
- </PRE>
- ********************************************************************************
- * 版权所有(c)
- *******************************************************************************/ #include "stdafx.h" #include <stdlib.h> #include <stdio.h> #include <string.h> #include <windows.h> #include <String.h> #define TITLE "DiskId32" // Required to ensure correct PhysicalDrive IOCTL structure setup #pragma pack(1) // Max number of drives assuming primary/secondary, master/slave topology #define MAX_IDE_DRIVES 4 #define IDENTIFY_BUFFER_SIZE 512 // #define m_cVxDFunctionIdesDInfo 1 #define SENDIDLENGTH sizeof (SENDCMDOUTPARAMS) + IDENTIFY_BUFFER_SIZE // IOCTL commands #define DFP_GET_VERSION 0x00074080 #define DFP_SEND_DRIVE_COMMAND 0x0007c084 #define DFP_RECEIVE_DRIVE_DATA 0x0007c088 #define FILE_DEVICE_SCSI 0x0000001b #define IOCTL_SCSI_MINIPORT_IDENTIFY ((FILE_DEVICE_SCSI << 16) + 0x0501) #define IOCTL_SCSI_MINIPORT 0x0004D008 // see NTDDSCSI.H for definition // GETVERSIONOUTPARAMS contains the data returned from the // Get Driver Version function. //获得硬件版本 typedef struct _GETVERSIONOUTPARAMS { //二进制驱动程序版本 // Binary driver version. BYTE bVersion; //二进制驱动程序修改// Binary driver revision. BYTE bRevision; //未使用 // Not used. BYTE bReserved; //IDE设置位图// Bit map of IDE devices. BYTE bIDEDeviceMap; //位掩码驱动能力 // Bit mask of driver capabilities. DWORD fCapabilities; //供将来使用// For future use DWORD dwReserved[4]; } GETVERSIONOUTPARAMS, *PGETVERSIONOUTPARAMS, *LPGETVERSIONOUTPARAMS; // Bits returned in the fCapabilities member of GETVERSIONOUTPARAMS // ATA ID command supported #define CAP_IDE_ID_FUNCTION 1 // ATAPI ID command supported #define CAP_IDE_ATAPI_ID 2 // SMART commannds supported #define CAP_IDE_EXECUTE_SMART_FUNCTION 4 // IDE registers typedef struct _IDEREGS { // Used for specifying SMART "commands". BYTE bFeaturesReg; // IDE sector count register BYTE bSectorCountReg; // IDE sector number register BYTE bSectorNumberReg; // IDE low order cylinder value BYTE bCylLowReg; // IDE high order cylinder value BYTE bCylHighReg; // IDE drive/head register BYTE bDriveHeadReg; // Actual IDE command. BYTE bCommandReg; // reserved for future use. Must be zero. BYTE bReserved; } IDEREGS, *PIDEREGS, *LPIDEREGS; // SENDCMDINPARAMS contains the input parameters for the // Send Command to Drive function. typedef struct _SENDCMDINPARAMS { // Buffer size in bytes DWORD cBufferSize; // Structure with drive register values. IDEREGS irDriveRegs; // Physical drive number to send BYTE bDriveNumber; // command to (0,1,2,3). // Reserved for future expansion. BYTE bReserved[3]; // For future use. DWORD dwReserved[4]; // Input buffer. BYTE bBuffer[1]; } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS; // Valid values for the bCommandReg member of IDEREGS. #define IDE_ATAPI_IDENTIFY 0xA1 // Returns ID sector for ATAPI. #define IDE_ATA_IDENTIFY 0xEC // Returns ID sector for ATA. // Status returned from driver typedef struct _DRIVERSTATUS { BYTE bDriverError; // Error code from driver, or 0 if no error. BYTE bIDEStatus; // Contents of IDE Error register. // Only valid when bDriverError is SMART_IDE_ERROR. BYTE bReserved[2]; // Reserved for future expansion. DWORD dwReserved[2]; // Reserved for future expansion. } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS; // Structure returned by PhysicalDrive IOCTL for several commands typedef struct _SENDCMDOUTPARAMS { DWORD cBufferSize; // Size of bBuffer in bytes DRIVERSTATUS DriverStatus; // Driver status structure. BYTE bBuffer[1]; // Buffer of arbitrary length in which to store the data read from the // drive. } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS; // The following struct defines the interesting part of the IDENTIFY // buffer: typedef struct _IDSECTOR { USHORT wGenConfig; USHORT wNumCyls; USHORT wReserved; USHORT wNumHeads; USHORT wBytesPerTrack; USHORT wBytesPerSector; USHORT wSectorsPerTrack; USHORT wVendorUnique[3]; CHAR sSerialNumber[20]; USHORT wBufferType; USHORT wBufferSize; USHORT wECCSize; CHAR sFirmwareRev[8]; CHAR sModelNumber[40]; USHORT wMoreVendorUnique; USHORT wDoubleWordIO; USHORT wCapabilities; USHORT wReserved1; USHORT wPIOTiming; USHORT wDMATiming; USHORT wBS; USHORT wNumCurrentCyls; USHORT wNumCurrentHeads; USHORT wNumCurrentSectorsPerTrack; ULONG ulCurrentSectorCapacity; USHORT wMultSectorStuff; ULONG ulTotalAddressableSectors; USHORT wSingleWordDMA; USHORT wMultiWordDMA; BYTE bReserved[128]; } IDSECTOR, *PIDSECTOR; typedef struct _SRB_IO_CONTROL { ULONG HeaderLength; UCHAR Signature[8]; ULONG Timeout; ULONG ControlCode; ULONG ReturnCode; ULONG Length; } SRB_IO_CONTROL, *PSRB_IO_CONTROL; // --------------------------------------------------- // (* Output Bbuffer for the VxD (rt_IdeDinfo record) *) typedef struct _rt_IdeDInfo_ { BYTE IDEExists[4]; BYTE DiskExists[8]; WORD DisksRawInfo[8*256]; } rt_IdeDInfo, *pt_IdeDInfo; // (* IdeDinfo "data fields" *) typedef struct _rt_DiskInfo_ { BOOL DiskExists; BOOL ATAdevice; BOOL RemovableDevice; WORD TotLogCyl; WORD TotLogHeads; WORD TotLogSPT; char SerialNumber[20]; char FirmwareRevision[8]; char ModelNumber[40]; WORD CurLogCyl; WORD CurLogHeads; WORD CurLogSPT; } rt_DiskInfo; class CGetMachineInfo { // Construction
- public: //Creat Function CGetMachineInfo(void);
- protected: //conversion to char string char *ConvertToString (DWORD diskdata [256], int firstIndex, int lastIndex); BOOL DoIDENTIFY (HANDLE hPhysicalDriveIOCTL, PSENDCMDINPARAMS pSCIP, PSENDCMDOUTPARAMS pSCOP, BYTE bIDCmd, BYTE bDriveNum, PDWORD lpcbBytesReturned); int ReadPhysicalDriveInNT (void); int ReadDrivePortsInWin9X (void); int ReadIdeDriveAsScsiDriveInNT (void); BOOL ReturnInfo(int drive, DWORD diskdata [256]); public: char HardDriveSerialNumber [1024]; CString str_DN_Modol; CString str_DN_Serial; CString str_DN_ControllerRevision; CString str_HardDeskSize; //硬件大小 CString str_HardDeskBufferSize; CString str_HardDeskType; CString str_HardDesk_Form; CString str_Controller; };