第一步
单击【开始】→【运行...】,输入cmd
2. 怎么查询硬盘序列号
1、首先敲击键盘的“WIN+R”键,然后在打开的运行窗口里输入cmd,再点确定。
3. C\C++如何获取硬盘的序列号和使用时间
可以试试使用WMI(在msdn上有详细的信息):
硬盘序列号: 用Win32_PhysicalMedia class.
CPU编号: 用Win32_Processor class.
BIOS编号: 用Win32_BIOS class.
下面例子取得硬盘的序列号,其他的用法也类似(msdn上的例子,把Win32_OperatingSystem改成了Win32_PhysicalMedia):
#define _WIN32_DCOM
#include <iostream>
using namespace std;
#include <comdef.h>
#include <Wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")
int main(int argc, char **argv)
{
HRESULT hres;
// Step 1: --------------------------------------------------
// Initialize COM. ------------------------------------------
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres))
{
cout << "Failed to initialize COM library. Error code = 0x"
<< hex << hres << endl;
return 1; // Program has failed.
}
// Step 2: --------------------------------------------------
// Set general COM security levels --------------------------
// Note: If you are using Windows 2000, you need to specify -
// the default authentication credentials for a user by using
// a SOLE_AUTHENTICATION_LIST structure in the pAuthList ----
// parameter of CoInitializeSecurity ------------------------
hres = CoInitializeSecurity(
NULL,
-1, // COM authentication
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
NULL, // Authentication info
EOAC_NONE, // Additional capabilities
NULL // Reserved
);
if (FAILED(hres))
{
cout << "Failed to initialize security. Error code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
// Step 3: ---------------------------------------------------
// Obtain the initial locator to WMI -------------------------
IWbemLocator *pLoc = NULL;
hres = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *) &pLoc);
if (FAILED(hres))
{
cout << "Failed to create IWbemLocator object."
<< " Err code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
// Step 4: -----------------------------------------------------
// Connect to WMI through the IWbemLocator::ConnectServer method
IWbemServices *pSvc = NULL;
// Connect to the root\cimv2 namespace with
// the current user and obtain pointer pSvc
// to make IWbemServices calls.
hres = pLoc->ConnectServer(
_bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace
NULL, // User name. NULL = current user
NULL, // User password. NULL = current
0, // Locale. NULL indicates current
NULL, // Security flags.
0, // Authority (e.g. Kerberos)
0, // Context object
&pSvc // pointer to IWbemServices proxy
);
if (FAILED(hres))
{
cout << "Could not connect. Error code = 0x"
<< hex << hres << endl;
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;
// Step 5: --------------------------------------------------
// Set security levels on the proxy -------------------------
hres = CoSetProxyBlanket(
pSvc, // Indicates the proxy to set
RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx
RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx
NULL, // Server principal name
RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx
RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
NULL, // client identity
EOAC_NONE // proxy capabilities
);
if (FAILED(hres))
{
cout << "Could not set proxy blanket. Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
// Step 6: --------------------------------------------------
// Use the IWbemServices pointer to make requests of WMI ----
// For example, get the name of the operating system
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_PhysicalMedia"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
if (FAILED(hres))
{
cout << "Query for physical media failed."
<< " Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
// Step 7: -------------------------------------------------
// Get the data from the query in step 6 -------------------
IWbemClassObject *pclsObj;
ULONG uReturn = 0;
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
if(0 == uReturn)
{
break;
}
VARIANT vtProp;
// Get the value of the Name property
hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, 0, 0);
wcout << "Serial Number : " << vtProp.bstrVal << endl;
VariantClear(&vtProp);
}
// Cleanup
// ========
pSvc->Release();
pLoc->Release();
pEnumerator->Release();
pclsObj->Release();
CoUninitialize();
return 0; // Program successfully completed.
}
4. 如何查看电脑硬盘序列号
电脑的硬盘是检测电脑质量的其中一个标准,在很多用户买电脑的时候呢,不少的人会把电脑的外观做得很精美漂亮,但是硬盘却不好,想查看电脑硬盘的型号,自己也不会。小编以下介绍的这几种办法都比较简单,只需要根据步骤就可以轻松搞定。
查看硬盘型号的方法一
在我们电脑中通常都会安装安全卫士,安全卫士的一个作用,就是帮助用户更好的管理电脑。要想查看电脑硬盘的型号,也可以通过安全卫士来查看。
首先打开安全卫士之后,在安全卫士的最底下,会发现有一个“功能大全”的图标,这个图标中含有了各种的检测,点进之后,找到一个“360硬件检测”,如果已经安装了360硬件检测的用户可以直接进入,没有安装过的用户则需要安装一下,安装好之后就可以通过这个软件去进行硬件型号检测和温度检测,在这里就可以查看电脑硬盘的型号。
查看电脑硬盘的方法二
除了安全卫士之外,“鲁大师”这一工具也深受很多用户的喜爱,利用鲁大师的检测工具也可以帮助用户们查看电脑的硬盘,这种办法跟上述中的360检测方法是差不多相似的,但鲁大师的检测功能相对要强大一些,同样的打开鲁大师工具之后,进行硬件检测就可以了。
查看电脑硬盘的方法三
这种办法就是通过桌面上的按钮来进行的,非常的简单,只需要打开“我的电脑”,在其中找到“属性”,再找到“设备管理器”,点进之后会看见一个“磁盘管理器”,通过这样就可以查看电脑的硬盘型号了。
Seagate硬盘型号命名规则
给自己扫盲 - -
举个例子来说吧!
希捷(ST)硬盘型号命名规则
以希捷1.5TB的ST31500341AS为例
ST 3 1500 3 4 1 AS
1 2 3 4 5 6 7
1. ST自然是Seagate的简写,表示希捷;
2. 3则是表示3.5英寸的桌面硬盘,9则表示2.5英寸的笔记本硬盘;
3. 1500自然是容量1500GB不用多说;
4. 这一位指的是硬盘的缓存数,7200.11硬盘中这个3表示32M 6表示16M 8表示8M,不过其他系列中,也有用2的次方数来表示缓存大小的,例如3就是2的三次方8M,4表示16M,5表示32M,7200.12系列的 ST3500418AS则是这种表示方法,缓存为16M;
5. 这个数字指的是盘片数,分别有1碟2碟3碟4碟,盘片自然越少性能越好;
6. 这里的1则是OEM版本号,也可能对应产地等因素,对硬盘的性能和其他参数没有影响;
7. 最后的AS指的是SATA接口,还有SV/AV指的是企业级的SATA和PATA硬盘,NS则是企业级的ES.2硬盘,CS是Pipeline HD系列影音硬盘,低功耗低噪音
希 捷的企业级硬盘在桌面硬盘里面还算是比较有名的,这里也稍微提一下,企业级硬盘中NS一般适合中小企业使用,而SV系列则一般是为了给视频监控等设备长期 密集使用而设计的,具有耐高温,低功耗,MTBF长等特点,所以鉴于其特点,所以也比较适合不少朋友拿来做BT,电驴下载盘,日夜不关机使用。NS和SV 系列没有太本质的区别,包括最新推出的Pipeline HD系列,也没有太大的区别,无非是性能,功耗,发热等各有偏重。
H表示Hitachi(日立);
D表示Deskstar系列;T travl系列(笔记本硬盘) S表示Standard标准(相对的还有A,表示自动);
数字开始~~~~
前:1-2
72表示硬盘转速为7200转/分;54 就是 5400咯
25表示该系列产品的最大容量为250GB;80表示该型号容量为80GB;
前:3-4
50 表示 硬盘的物理容量为 500G,其他的你可以猜一下~一般比标的大的多,硬盘可以扩容已经是业界公开的秘密啦~~ 前:5-6
32 表示 320G 比前面的数字要小,其他的自己猜~ 前:7
片片数 1 单碟 2 双碟 3 自己猜去~~
7和8有关系, 一个片是2面, 2个就4面但是有的会少。。。我的硬盘 直接是 3面,也就是还有一面是空的~ 可以开启的啊哈哈~
字母:
V表示硬盘代数(7K250系列都是字母V);L表示硬盘的高度为1英寸(T代表0.49英寸,N代表0.37英寸);SA表示SATA(AT则表示ATA);2表示缓存为2MB(8代表8MB);0表示保留值。
5. 怎样在vc++中获得硬盘的序列号
vc++中获得硬盘的序列号可以参考如下代码:
//MyDiskInfo.h头文件
#pragma once
class MyDiskInfo
{
public:
MyDiskInfo(void);
public:
~MyDiskInfo(void);
public:
int GetDiskInfo(int driver=0);
char szModelNumber[64];
char szSerialNumber[64];
};
//MyDiskInfo.cpp文件
// MyDiskInfo.cpp: implementation of the CMyDiskInfo class.
//
#include "stdafx.h"
#include "MyDiskInfo.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
const WORD IDE_ATAPI_IDENTIFY = 0xA1; // 读取ATAPI设备的命令
const WORD IDE_ATA_IDENTIFY = 0xEC; // 读取ATA设备的命令
#define _WIN32_WINNT 0x0400
#include "winioctl.h"
//#include "NTDDSCSI.h"
// Construction/Destruction
MyDiskInfo::MyDiskInfo(void)
{
}
MyDiskInfo::~MyDiskInfo(void)
{
}
BOOL __fastcall DoIdentify( HANDLE hPhysicalDriveIOCTL,
PSENDCMDINPARAMS pSCIP,
PSENDCMDOUTPARAMS pSCOP,
BYTE btIDCmd,
BYTE btDriveNum,
PDWORD pdwBytesReturned)
{
pSCIP->cBufferSize = IDENTIFY_BUFFER_SIZE;
pSCIP->irDriveRegs.bFeaturesReg = 0;
pSCIP->irDriveRegs.bSectorCountReg = 1;
pSCIP->irDriveRegs.bSectorNumberReg = 1;
pSCIP->irDriveRegs.bCylLowReg = 0;
pSCIP->irDriveRegs.bCylHighReg = 0;
pSCIP->irDriveRegs.bDriveHeadReg = (btDriveNum & 1) ? 0xB0 : 0xA0;
pSCIP->irDriveRegs.bCommandReg = btIDCmd;
pSCIP->bDriveNumber = btDriveNum;
pSCIP->cBufferSize = IDENTIFY_BUFFER_SIZE;
return DeviceIoControl( hPhysicalDriveIOCTL,
SMART_RCV_DRIVE_DATA,
(LPVOID)pSCIP,
sizeof(SENDCMDINPARAMS) - 1,
(LPVOID)pSCOP,
sizeof(SENDCMDOUTPARAMS) + IDENTIFY_BUFFER_SIZE - 1,
pdwBytesReturned, NULL);
}
char *__fastcall ConvertToString(DWORD dwDiskData[256], int nFirstIndex, int nLastIndex)
{
static char szResBuf[1024];
char ss[256];
int nIndex = 0;
int nPosition = 0;
for(nIndex = nFirstIndex; nIndex <= nLastIndex; nIndex++)
{
ss[nPosition] = (char)(dwDiskData[nIndex] / 256);
nPosition++;
// Get low BYTE for 2nd character
ss[nPosition] = (char)(dwDiskData[nIndex] % 256);
nPosition++;
}
// End the string
ss[nPosition] = '\0';
int i, index=0;
for(i=0; i <nPosition; i++)
{
if(ss[i]==0 || ss[i]==32) continue;
szResBuf[index]=ss[i];
index++;
}
szResBuf[index]=0;
return szResBuf;
}
int MyDiskInfo::GetDiskInfo(int driver)
{
char sFilePath[64]={0};
sprintf(sFilePath,"\\\\.\\PHYSICALDRIVE%d",driver);//modify by lonkil 2008-07-13
HANDLE hFile = INVALID_HANDLE_VALUE;
hFile = ::CreateFile(sFilePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING,
0, NULL);
if (hFile == INVALID_HANDLE_VALUE) return -1;
DWORD dwBytesReturned;
GETVERSIONINPARAMS gvopVersionParams;
DeviceIoControl(hFile,
SMART_GET_VERSION,
NULL,
0,
&gvopVersionParams,
sizeof(gvopVersionParams),
&dwBytesReturned, NULL);
if(gvopVersionParams.bIDEDeviceMap <= 0) return -2;
// IDE or ATAPI IDENTIFY cmd
int btIDCmd = 0;
SENDCMDINPARAMS InParams;
int nDrive =0;
btIDCmd = (gvopVersionParams.bIDEDeviceMap >> nDrive & 0x10) ? IDE_ATAPI_IDENTIFY : IDE_ATA_IDENTIFY;
// 输出参数
BYTE btIDOutCmd[sizeof(SENDCMDOUTPARAMS) + IDENTIFY_BUFFER_SIZE - 1];
if(DoIdentify(hFile,
&InParams,
(PSENDCMDOUTPARAMS)btIDOutCmd,
(BYTE)btIDCmd,
(BYTE)nDrive, &dwBytesReturned) == FALSE) return -3;
::CloseHandle(hFile);
DWORD dwDiskData[256];
USHORT *pIDSector; // 对应结构IDSECTOR,见头文件
pIDSector = (USHORT*)((SENDCMDOUTPARAMS*)btIDOutCmd)->bBuffer;
for(int i=0; i < 256; i++) dwDiskData[i] = pIDSector[i];
// 取系列号
ZeroMemory(szSerialNumber, sizeof(szSerialNumber));
strcpy(szSerialNumber, ConvertToString(dwDiskData, 10, 19));
// 取模型号
ZeroMemory(szModelNumber, sizeof(szModelNumber));
strcpy(szModelNumber, ConvertToString(dwDiskData, 27, 46));
return 0;
}
6. 电脑硬盘序列号怎么查询
1、按Win+R打开运行,输入cmd,回车;
7. 关于C语言程序在一个固定电脑中运行,读取硬盘序列号的问题
之前收集的获取硬盘信息的函数语言是C++,可以成功获得硬盘驱动器的信息,希望能帮到您
void
CGetdiskinfo(DWORD
*dwNum,char
chDriveInfo[][256])//获取硬盘信息
{
DWORD
DiskCount
=
0;
//利用GetLogicalDrives()函数可以获取系统中逻辑驱动器的数量,函数返回的是一个32位无符号整型数据。
DWORD
DiskInfo
=
GetLogicalDrives();
//通过循环操作查看每一位数据是否为1,如果为1则磁盘为真,如果为0则磁盘不存在。
while(DiskInfo)
{
//通过位运算的逻辑与操作,判断是否为1
//Sleep(10);
if(DiskInfo&1)
{
DiskCount++;
}
DiskInfo
=
DiskInfo
>>
1;//通过位运算的右移操作保证每循环一次所检查的位置向右移动一位。*/
}
//
if
(*dwNum
<
DiskCount)
//
{
//
return;//实际的磁盘数目大于dwNum
//
}
*dwNum
=
DiskCount;//将磁盘分区数量保存
//-------------------------------------------------------------------//
//通过GetLogicalDriveStrings()函数获取所有驱动器字符串信息长度
int
DSLength
=
GetLogicalDriveStrings(0,NULL);
//
WCHAR*
DStr
=
new
WCHAR[DSLength];
char
*DStr=new
char[DSLength];
memset(DStr,0,DSLength);
//通过GetLogicalDriveStrings将字符串信息复制到堆区数组中,其中保存了所有驱动器的信息
8. linux下怎么用c获取硬盘物理序列号
1、在Linux系统中通过C语言获取硬盘序列号,可以借助于ioctl()函数,该函数原型如下:
intioctl(intfd,unsignedlongrequest,...);
ioctl的第一个参数是文件标识符,用open()函数打开设备时获取。
ioctl第二个参数为用于获得指定文件描述符的标志号,获取硬盘序列号,一般指明为HDIO_GET_IDENTITY。
ioctl的第三个参数为一些辅助参数,要获取硬盘序列号,需要借助于structhd_driveid结构体来保存硬盘信息,该结构体在Linux/hdreg.h中,structhd_driveid的声明如下
structhd_driveid{
unsignedshortconfig;/lotsofobsoletebitflags*/
unsignedshortcyls;/*Obsolete,"physical"cyls*/
unsignedshortreserved2;/*reserved(word2)*/
unsignedshortheads;/*Obsolete,"physical"heads*/
unsignedshorttrack_bytes;/*unformattedbytespertrack*/
unsignedshortsector_bytes;/*unformattedbytespersector*/
unsignedshortsectors;/*Obsolete,"physical"sectorspertrack*/
unsignedshortvendor0;/*vendorunique*/
unsignedshortvendor1;/*vendorunique*/
unsignedshortvendor2;/*Retiredvendorunique*/
unsignedcharserial_no[20];/*0=not_specified*/
unsignedshortbuf_type;/*Retired*/
unsignedshortbuf_size;/*Retired,512byteincrements
*0=not_specified
*/
……
};
2、源代码如下
#include<stdio.h>
//ioctl()的声明头文件
#include<sys/ioctl.h>
//硬盘参数头文件,hd_driveid结构声明头文件
#include<linux/hdreg.h>
//文件控制头文件
#include<sys/fcntl.h>
intmain()
{
//用于保存系统返回的硬盘数据信息
structhd_driveidid;
//这里以第一块硬盘为例,用户可自行修改
//用open函数打开获取文件标识符,类似于windows下的句柄
intfd=open("/dev/sda",O_RDONLY|O_NONBLOCK);
//失败返回
if(fd<0){
perror("/dev/sda");
return1;}
//调用ioctl()
if(!ioctl(fd,HDIO_GET_IDENTITY,&id))
{
printf("SerialNumber=%s ",id.serial_no);
}
return0;
}
编译完成后,执行效果如下:
9. 怎样查看硬盘序列号
查看硬盘序列号方法,操作方法如下。
1、首先进入系统按Win+R打开运行面板,输入cmd按回车键。