unit CommonUnit;

 interface

 uses
Windows, SysUtils, DateUtils; Const
CPUVendorIDs: array [ .. ] of string = ('GenuineIntel', 'UMC UMC UMC',
'AuthenticAMD', 'CyrixInstead', 'NexGenDriven', 'CentaurHauls');
// 将CPU厂家信息转换成字串形式
CPUVendors: array [ .. ] of string = ('Intel', 'UMC', 'AMD', 'Cyrix',
'NexGen', 'CentaurHauls'); type
TVendor = array [ .. ] of AnsiChar; { 将AnsiString的乱码转换成能正常显示的Utf8编码的字符串 }
function DecodeUtf8Str(const S: string): WideString;
function DateToInt64(date: TDateTime): Int64;
function Int64ToDate(num: Int64): TDateTime; function GetCPUID: string;
function GetIdeSerialNumber: string;
function GetCPUVendor: TVendor;
function GetCPUV: string; implementation function DecodeUtf8Str(const S: string): WideString;
var
lenSrc, lenDst: Integer;
begin
lenSrc := Length(S);
if (lenSrc = ) then
Exit;
lenDst := MultiByteToWideChar(CP_UTF8, , Pointer(S), lenSrc, nil, );
SetLength(Result, lenDst);
MultiByteToWideChar(CP_UTF8, , Pointer(S), lenSrc, Pointer(Result), lenDst);
end; function DateToInt64(date: TDateTime): Int64;
var
Bias: Integer;
a1, a2: Extended;
T1, T2: TDateTime;
TS, TS2: TTimeStamp;
pTime: _TIME_ZONE_INFORMATION;
begin
GetTimeZoneInformation(pTime); // 获取时区
Bias := pTime.Bias;
T1 := IncMinute(date, Bias);
T2 := EncodeDateTime(, , , , , , );
TS := DateTimeToTimeStamp(T1);
TS2 := DateTimeToTimeStamp(T2);
a1 := TimeStampToMSecs(TS);
a2 := TimeStampToMSecs(TS2); Result := StrToInt64Def(FloatToStr(a1 - a2), );
end; function Int64ToDate(num: Int64): TDateTime;
var
Bias: Integer;
a1, a2: Extended;
T1, T2: TDateTime;
TS, TS2: TTimeStamp;
pTime: _TIME_ZONE_INFORMATION;
begin
GetTimeZoneInformation(pTime); // 获取时区
Bias := pTime.Bias;
// Bias := Bias + pTime.DaylightBias;
T2 := EncodeDateTime(, , , , , , );
TS2 := DateTimeToTimeStamp(T2);
a2 := TimeStampToMSecs(TS2);
a1 := StrToFloat(IntToStr(num));
TS := MSecsToTimeStamp(a1 + a2);
T1 := TimeStampToDateTime(TS);
T1 := IncMinute(T1, -Bias);
Result := T1;
end; function GetCPUID: string;
procedure SetCPU(Handle: THandle; CPUNO: Integer);
var
ProcessAffinity: Cardinal;
_SystemAffinity: Cardinal;
begin
GetProcessAffinityMask(Handle, ProcessAffinity, _SystemAffinity);
ProcessAffinity := CPUNO;
SetProcessAffinityMask(Handle, ProcessAffinity);
end; const
CPUINFO = '%s-%.8x%.8x';
var
iEax: Integer;
iEbx: Integer;
iEcx: Integer;
iEdx: Integer;
begin
SetCPU(GetCurrentProcess, );
asm
push ebx
push ecx
push edx
mov eax,
DW $A20F// cpuid
mov iEax, eax
mov iEbx, ebx
mov iEcx, ecx
mov iEdx, edx
pop edx
pop ecx
pop ebx
end
; Result := Format(CPUINFO, [GetCPUV, iEdx,iEax]);
end; function GetCPUV: string;
var
Vendor: string;
VendorID, I: Integer;
begin
Vendor := GetCPUVendor;
{for I := 0 to High(CPUVendorIDs) do
begin
If Vendor = CPUVendorIDs[I] then
begin
Vendor := CPUVendorIDs[I];
VendorID := I;
break;
end;
end; }
Result := Vendor;
end; // 获取CPU厂家信息,返回值为TVendor类型
function GetCPUVendor: TVendor;assembler;register;
asm
PUSH EBX
PUSH EDI
MOV EDI,EAX
MOV EAX,
DW $A20F // CPUID指令
MOV EAX,EBX
XCHG EBX,ECX
MOV ECX,
@:
STOSB
SHR EAX,
LOOP @
MOV EAX,EDX
MOV ECX,
@:
STOSB
SHR EAX,
LOOP @
MOV EAX,EBX
MOV ECX,
@:
STOSB
SHR EAX,
LOOP @
POP EDI
POP EBX
end; function GetIdeSerialNumber: string; // 获取硬盘的出厂系列号;
var
RootPath: array [ .. ] of char;
VolName: array [ .. ] of char;
SerialNumber: DWORD;
MaxCLength: DWORD;
FileSysFlag: DWORD;
FileSysName: array [ .. ] of char;
begin
RootPath := 'C:\'; GetVolumeInformation(RootPath, VolName, , @SerialNumber, MaxCLength,
FileSysFlag, FileSysName, );
Result := Format('%s', [IntToHex(SerialNumber, )]);
end; end.

获取CPUID等的更多相关文章

  1. java支持跨平台获取cpuid、主板id、硬盘id、mac地址 (兼容windows、Linux)

    windows: package cn.net.comsys.helper.system.info;   import java.io.BufferedReader; import java.io.F ...

  2. C#获取CPUID(MD5输出),网卡ID,主DNS,备用DNS

    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...

  3. C#-获取CPUID

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  4. 获取硬件信息的delphi源码CPUID、操作系统、Mac物理地址、计算机名称、IP地址、用户名

    {-----------------------------------------------------------------------------作者:sushengmiyan 2013.0 ...

  5. C# 获取计算机信息

    //C#获取当前计算机的系统信息 //系统标识符和版本号 string strSystem = Environment.OSVersion.ToString(); //获取映射到进程上下文的物理内存量 ...

  6. WMI 获取硬件信息的封装函数与获取联想台式机的出厂编号方法

    原文:WMI 获取硬件信息的封装函数与获取联想台式机的出厂编号方法 今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都是可以提取出来的,就自己把那些公共部分提出出来,以后如果要获取 某部分的 ...

  7. 本地服务器硬件信息获取指令wmic

    获取BIOS序列号 wmic bios list full | find "SerialNumber" SerialNumber=P50168VB 获取CPUID(WIN32_PR ...

  8. 获取本地机器的特征码IP MAC

    using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Ma ...

  9. c#中如何获取本机MAC地址、IP地址、硬盘ID、CPU序列号等系统信息

    我们在利用C#开发桌面程序(Winform)程序的时候,经常需要获取一些跟系统相关的信息,例如用户名.MAC地址.IP地址.硬盘ID.CPU序列号.系统名称.物理内存等. 首先需要引入命名空间: us ...

随机推荐

  1. JVM底层又是如何实现synchronized的

    目前在Java中存在两种锁机制:synchronized和Lock,Lock接口及其实现类是JDK5增加的内容,其作者是大名鼎鼎的并发专家Doug Lea.本文并不比较synchronized与Loc ...

  2. [转]AppCompat 22.1,Goole暴走,MD全面兼容低版本

    AppCompat 22.1,Goole暴走,MD全面兼容低版本 分类: Android2015-04-24 09:48 1354人阅读 评论(0) 收藏 举报 android   目录(?)[+] ...

  3. LeetCode Factorial Trailing Zeroes

    原题链接在这里:https://leetcode.com/problems/factorial-trailing-zeroes/ 求factorial后结尾有多少个0,就是求有多少个2和5的配对. 但 ...

  4. Sequential Read Ahead For SQL Server

    Balancing CPU and I/O throughput is essential to achieve good overall performance and to maximize ha ...

  5. ELK-Python(三)

    不具有通用性,留作纪念. [root@GXB-CTRLCENTER python]# cat insert_uv.py #!/usr/bin/env python # -*- coding:utf-8 ...

  6. python or not python

    python or not python 我挺喜欢 python 这种编程语言,它本身的丰富的动态特性让这种语言的表达能力很强,基本上 python 上写的一行代码,可实现 java 上 1.5 到 ...

  7. Java代码中执行Linux命令,亲测可用

    前提需要知道怎么在linux怎么新建java文件和怎么编译,否则请先学其他知识!! import java.io.*;public class Test{ public static void mai ...

  8. Spring Boot 2 Swagger2

    本文将介绍RESTful API的重磅好伙伴Swagger2,它可以轻松的整合到Spring Boot中,并与Spring MVC程序配合组织出强大RESTful API文档. 它既可以减少我们创建文 ...

  9. 读取plist

    - (NSArray *)imageData { if (_imageData == nil) { // 从未初始化 // 初始化数据 // File : 全路径 // NSBundle : 一个NS ...

  10. RPC、SQL、NFS属于OSI的哪一层

    第一层:物理层 第二层:数据链路层 802.2.802.3ATM.HDLC.FRAME RELAY 第三层:网络层 IP.IPX.ARP.APPLETALK.ICMP 第四层:传输层 TCP.UDP. ...