第一步
單擊【開始】→【運行...】,輸入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按回車鍵。