Home > Back-end >  How to access the hard disk serial number under win10
How to access the hard disk serial number under win10

Time:11-04

HDevice:=CreateFile (' \ \. \ PhysicalDrive0 'GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);

The code above is not working under win10

CodePudding user response:

Through WMI access to network card MAC address, the hard disk serial number, serial number into the main board, CPU ID, the BIOS serial number
Delphi system information captured by the WMI
USES the ActiveX, ComObj;

The function GetWMIProperty (WMIType, WMIProperty: string) : string;
Var
Wmi, Objs, Obj: OleVariant;
Enum: IEnumVariant;
C: the Cardinal;
The begin
Wmi:=CreateOleObject (' WbemScripting. SWbemLocator ');
Objs:=Wmi. ConnectServer (', 'root/cimv2). ExecQuery (' Select * from Win32_' + WMIType);
Enum:=IEnumVariant (IUnknown (Objs. _NewEnum));
Enum. Reset;
Enum. Next, 1, Obj, C);
Obj:=Obj. Properties_. Item (WMIProperty, 0). The Value;
The Result: Obj=;
end;


//get the hard disk serial number
ShowMessage (GetWMIProperty (' DiskDrive ', 'PNPDeviceID'));
//get BISO serial number
ShowMessage (GetWMIProperty (' BIOS ', 'SerialNumber));
//access to network card MAC address
ShowMessage (GetWMIProperty (' NetworkAdapter ', 'MACAddress));
//access card serial number
ShowMessage (GetWMIProperty (' NetworkAdapter ', 'PNPDeviceID'));
//get the CPU serial number
ShowMessage (GetWMIProperty (' Processor ', 'ProcessorId'));

Can also use the same method for arbitrary system information of interest, such as the running process, account information, etc.,

More information on the WMI reference:
http://www.microsoft.com/whdc/system/pnppwr/wmi/default.mspx
http://msdn2.microsoft.com/en-us/library/aa394572.aspx

CodePudding user response:

GetWMIProperty (' DiskDrive ', 'SerialNumber) won the first disk devices labeled//

CodePudding user response:

Two or three floor are positive solutions,
Is directly given by the code on the second floor, third floor is for baidu have the source code of the function name,

CodePudding user response:

Charge can find my qq: 171833017, can be applied to the development of a variety of popular language, such as Delphi, c + + Builder, c #, Visual c + +, Visual Basic, Visual Basic.NET, original concept such as
1. Supports Windows, xp and above system, support 64 - bit operating system, support U disk/mobile hard disk, does not support win98 and under the operating system,
2. Only a DLL,
3. Under the Windows 7/doing system, no need administrator privileges,
4. Support to drive access physical sequence number of hard disk, support for disk type,
5. Support access to hard disk temperature, smart information,
Download address http://www.dxmylove.com/download/jyharddisk.zip

CodePudding user response:

This method is simple to use on the second floor,
Before the cpuid are using the assembly code on the net access, multi-core also change back and forth,

CodePudding user response:

Mark, access to the hard disk serial number,

CodePudding user response:

This code is not working under win10
  • Related