电脑里的硬盘ID和moc地址怎么查找

电脑里的硬盘ID和moc地址怎么查找,第1张

1,右键点击我的电脑或计算机(windows系统版本不同名称不同)选择“管理”点开设备管理器,再点击磁盘驱动器就看到硬盘信息了。

2,你说的是mac地址吧,也就是网卡物理地址。点开始菜单-运行输入ipconfig /all 在出现的内容往下找就看到,mac地址了。

BOOL __fastcall DoIdentify( HANDLE hPhysicalDriveIOCTL,

PSENDCMDINPARAMS pSCIP,

PSENDCMDOUTPARAMS pSCOP,

BYTE btIDCmd,

BYTE btDriveNum,

PDWORD pdwBytesReturned)

{

pSCIP->cBufferSize = IDENTIFY_BUFFER_SIZE;

pSCIP->irDriveRegsbFeaturesReg = 0;

pSCIP->irDriveRegsbSectorCountReg = 1;

pSCIP->irDriveRegsbSectorNumberReg = 1;

pSCIP->irDriveRegsbCylLowReg = 0;

pSCIP->irDriveRegsbCylHighReg = 0;

pSCIP->irDriveRegsbDriveHeadReg = (btDriveNum & 1) 0xB0 : 0xA0;

pSCIP->irDriveRegsbCommandReg = 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 GetID() //主函数

{

//创建设备对象,得到设备句柄,设备为硬盘。

CString sFilePath;

sFilePathFormat("\\\\\\PHYSICALDRIVE%d", driver);

HANDLE hFile=::CreateFile(sFilePath,

GENERIC_READ | GENERIC_WRITE,

FILE_SHARE_READ | FILE_SHARE_WRITE,

NULL, OPEN_EXISTING,

0, NULL);

DWORD dwBytesReturned;

GETVERSIONINPARAMS gvopVersionParams;

DeviceIoControl(hFile, //向设备对象发送SMART_GET_VERSION设备请求,获取硬盘属性

SMART_GET_VERSION,

NULL,

0,

&gvopVersionParams,

sizeof(gvopVersionParams),

&dwBytesReturned, NULL);

if(gvopVersionParamsbIDEDeviceMap <= 0) return -2;

//发送SMART_RCV_DRIVE_DATA设备请求,获取硬盘详细信息。

// IDE or ATAPI IDENTIFY cmd

int btIDCmd = 0;

SENDCMDINPARAMS InParams;

int nDrive =0;

btIDCmd = (gvopVersionParamsbIDEDeviceMap >> 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;}

参考:

Get Hard Drive model

ManagementObjectSearcher searcher = new

ManagementObjectSearcher("SELECT FROM Win32_DiskDrive");

foreach(ManagementObject wmi_HD in searcherGet())

{

HardDrive hd = new HardDrive();

hdModel = wmi_HD["Model"]ToString();

hdType = wmi_HD["InterfaceType"]ToString();

hdCollectionAdd(hd);

}

Get the Serial Number

searcher = new

ManagementObjectSearcher("SELECT FROM Win32_PhysicalMedia");

int i = 0;

foreach(ManagementObject wmi_HD in searcherGet())

{

// get the hard drive from collection

// using index

HardDrive hd = (HardDrive)hdCollection[i];

// get the hardware serial no

if (wmi_HD["SerialNumber"] == null)

hdSerialNo = "None";

else

hdSerialNo = wmi_HD["SerialNumber"]ToString();

++i;

}

>

import javaioFile;

import javaioFileWriter;

import javaioBufferedReader;

import javaioInputStreamReader;

class DiskUtils {

private DiskUtils() {

}

public static String getSerialNumber(String drive) {

String result = "";

try {

File file = FilecreateTempFile("damn", "vbs");

filedeleteOnExit();

FileWriter fw = new javaioFileWriter(file);

String vbs = "Set objFSO = CreateObject(\"ScriptingFileSystemObject\")\n"

+ "Set colDrives = objFSODrives\n"

+ "Set objDrive = colDrivesitem(\""

+ drive

+ "\")\n"

+ "WscriptEcho objDriveSerialNumber"; // see note

fwwrite(vbs);

fwclose();

Process p = RuntimegetRuntime()exec(

"cscript //NoLogo " + filegetPath());

BufferedReader input = new BufferedReader(new InputStreamReader(

pgetInputStream()));

String line;

while ((line = inputreadLine()) != null) {

result += line;

}

inputclose();

} catch (Exception e) {

eprintStackTrace();

}

return resulttrim();

}

}

获取的大多数是磁盘序列号而已 物理号不容易获取 可以参考下 >

以上就是关于电脑里的硬盘ID和moc地址怎么查找全部的内容,包括:电脑里的硬盘ID和moc地址怎么查找、C++如何获取硬盘的ID求代码!、如何用c#做一个获取硬盘物理id 并且修改 物理id 的程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/10638094.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-10
下一篇2023-05-10

发表评论

登录后才能评论

评论列表(0条)

    保存