Classes for obtaining physical information on hard disks

Source: Internet
Author: User

Introduced:

There are a lot of times I need to know some of the machine's physical information (such as activation technology), so I use the time to leave the college entrance examination, encapsulating a hard disk to obtain the physical information of the class, to facilitate everyone. This class tests the effect on my machine as follows:

Cgetmachineinfo Class Introduction:

Class Name: Cgetmachineinfo
Some of the functions to be described in a class are:

Function

int readphysicaldriveinnt (void) Read the physical information of the hard drive under NT kernel system
int Readdriveportsinwin9x (void) Read physical information for hard drives under 9X kernel system
int readidedriveasscsidriveinnt (void) Read the physical information for the SCSI hard drive under the NT system
BOOL returninfo (int drive, DWORD Diskdata [256]) Collect disk physical information main function
Char *converttostring (DWORD, int, int)

Converts an integer variable to a string
Cgetmachineinfo (void); class to differentiate the system kernel and start collecting information automatically
Some variables to be described in a class:

Variable description

CString Str_dn_modol The factory serial number of the hard drive
CString str_dn_serial Sequential serial number of drive
CString str_dn_controllerrevision Hard Drive version
CString str_harddesksize Size of hard disk (bytes)
CString str_harddeskbuffersize Hard disk Cache size (bytes)
CString Str_harddesktype Hard disk Type
CString Str_controller Indicates whether the hard drive is an active or auxiliary disk
CString Str_harddesk_form Description of the information taken from the computer on the first few hard drives

Using the Cgetmachineinfo library:

I used a dialog based program to test this class, and I constructed this object in the initialization function of the dialog box, because the constructor of the class automatically collects the information, so we can directly access the information it gets when we construct a class variable. The code is as follows:

BOOL CHardDeskInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog(); CGetMachineInfo m_Info; //构造这个类的变量
SetDlgItmText(IDC_HARDDESK_ID,m_Info.str_DN_Modol);//直接访问它收集到的信息
SetDlgItemText(IDC_STATIC_SERIAL,m_Info.str_DN_Serial);
SetDlgItemText(IDC_STATIC_CR,m_Info.str_DN_ControllerRevision);
SetDlgItemText(IDC_HARDDESK_SIZE,m_Info.str_HardDeskSize+" bytes");
SetDlgItemText(IDC_BUFFER_SIZE,m_Info.str_HardDeskBufferSize+" bytes");
SetDlgItemText(IDC_HARDDESK_TYPE,m_Info.str_HardDeskType);
SetDlgItemText(IDC_STATIC_Controller,m_Info.str_Controller);
......//
return TRUE; // 除非设置了控件的焦点,否则返回 TRUE
}

End:

This class is very easy to use, detailed you can see the source code (haste may be wrong, please elder sister more inclusive).

Test program compiled by VC + + 7.0, class can be used for ... About 5.0 of all VC versions?

This article supporting source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.