The hard disk Serial Number (Serial Number) is not equal to the Volume Name. Although the latter is easy to obtain, it will be overwritten after formatting the partition, which is unreliable. Unfortunately, many friends often cannot tell this point.
To obtain the physical
());
}
}
// Obtain the first hard disk number
Public string getharddiskid ()
{
Try
{
Managementobjectsearcher searcher = new managementobjectsearcher ("select * from win32_physicalmedia ");
String strharddiskid = null;
Foreach (managementobject mo in searcher. get ())
{
Strharddiskid = mo ["serialnumber"]. tostring (). trim ();
Break;
}
Return strharddiskid;
}
Catch
{
Return "";
}
} // End
// Obtain the di
(){Var bfUsb;BfUsb = CheckUsb ();If (bfUsb = true){Var locator = new ActiveXObject ("WbemScripting. SWbemLocator ");Var computer = locator. ConnectServer (".");Var properties = computer. ExecQuery ("SELECT * FROM Win32_USBHub ");Var e = new Enumerator (properties );Var arrayUsbSN = new Array (); // stores the serial numberVar intCount = 0;For (;! E. atEnd (); e. moveNext ()){Var p = e. item ();Var strSN;Var uSerialNum;Var sn = p. DeviceIDIf (sn. inde
MAC address of the NIC
Select macaddress from win32_networkadapter where (macaddress is not null) and (manufacturer
Result: 08: 00: 46: 63: FF: 8C
Serial number of the CPU
Select processorid from win32_processor
Result: 3febf9ff00000f24
Motherboard serial number
Select serialnumber from win32_bios
Result: 2836
Getting the serial number is the information to read the soft hard disc, which can be obtained by using the following function:
Public Declare Function getvolumeinformation Lib "kernel32.dll" Alias "Getvolumeinformationa" (ByVal lpRootPathName as St Ring, ByVal Lpvolumenamebuffer as String, ByVal nvolumenamesize as Integer, Lpvolumeserialnumber as Long, Lpmaximu
1. Obtain the CPU ID
DWORD cdlgregister: getcpuid ()
2. Obtain the serial number of the hard drive C.
DWORD cdlgregister: getharddisknum ()
Code for getting CPU information:
# Include "windows. H "
Hard disk
private void GetInfo (){String cpuInfo = "";//cpu serial numberManagementClass cimobject = new ManagementClass ("Win32_Processor");Managementobjectcollection MOC = Cimobject. GetInstances ();foreach (ManagementObject mo in MOC){CpuInfo = mo. properties["Processorid"]. Value.tostring ();Response.Write ("CPU serial Nu
. Path! = ":")
{
BfResult = true;
}
}
}
Return bfResult;
}
Function ReadUsbSN ()
{
Var bfUsb;
BfUsb = CheckUsb ();
If (bfUsb = true)
{
Var locator = new ActiveXObject ("WbemScripting. SWbemLocator ");
Var computer = locator. ConnectServer (".");
Var properties = computer. ExecQuery ("SELECT * FROM Win32_USBHub ");
Var e = new Enumerator (properties );
Var arrayUsbSN = new Array (); // stores the serial number
First load. dll, assembly. Load ("XXX. dll ");And then reflection.The premise of reflection is the sameProgramSet. You can compile different namespaces into the same set of programs.Classes in the same namespace can be reflected to objects by class names, but other namespaces cannot (with space restrictions added). I don't know why; find another program to obtain the hard disk serial
// Obtain the serial number of the hard disk:
Function getideserialnumber: pchar; // gets the factory serial number of the hard disk;
Const
Identify_buffer_size = 512;
Type
Tideregs = packed record
Bfeaturesreg: byte;
Bsectorcounr
Code for reading the serial number of usb hdd (USB mobile hard disk Information)
Code, model, and split of the serial number of the usb hdd.
Visual Studio 2010 is successfully compiled.
The Code uses the related code in smartata. c In CrystalDiskInfo:
The following connectio
Code for reading the serial number of usb hdd (USB mobile hard disk information), USB HDD
Code, model, and split of the serial number of the usb hdd.
Visual Studio 2010 is successfully compiled.
The Code uses the related code in smartata. c In CrystalDiskInfo:
The following
C # How to obtain the physical serial number of a hard disk
Using system;Using system. runtime. interopservices;Using system. Management;Namespace hardware{/// /// Summary of hardware_mac./// Public class hardwareinfo{// Obtain the machine namePublic String gethostname (){Return System. net. DNS. gethostname ();}
// obtain the CPU
C # ask for help when getting the hard disk serial number,
The specific problem is as follows: I used the following code to obtain the hard disk information to create an exe file. When testing on the machine, the result of double-click operation is different from that of running as administrator. How can this problem
Brief introduction:
Pjsecure is a C-style Win32 dynamic link library, which can be used to realize the network Copy registration function of software products.
Quickly obtain the network card address of the remote machine by calling the RCP function uuidcreate or uuidcreatesequential.
The export function in Pjsecure uniquely identifies a computer based on two information. The first function gets the NIC address of the installed NIC, which is a 12-digit nu
Using System;Using System. Runtime. InteropServices;Using System. Management;Namespace Hardware{/// /// Summary of Hardware_Mac./// Public class HardwareInfo{// Obtain the machine namePublic string GetHostName (){Return System. Net. Dns. GetHostName ();}
// Obtain the CPU IDPublic String GetCpuID (){Try{ManagementClass mc = new ManagementClass ("Win32_Processor ");ManagementObjectCollection moc = mc. GetInstances ();
String strCpuID = null;Foreach (ManagementObject mo in moc){StrCpuID = mo. Prop
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.