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. Selenium2学习-019-WebUI自动化实战实例-017-获取浏览器类型

    Web UI 自动化脚本分布执行过程中有时候需要获取浏览器的相关信息,此文给出了一个简略获取浏览器类型的方法,敬请各位小主们参阅.若有不足之处,敬请大神指正,不胜感激! 闲话少述,上码. /** * ...

  2. SQL Server select 将类型相同的行合并,并将对应金额相加

    select Category,REPLACE(sum(Amount),'-','')  as Amountfrom T_Detail WHERE CREATED_BY='6123EC14-50E2- ...

  3. css中的zoom的使用

    css中的zoom的使用  zoom : normal | number  normal : 默认值.使用对象的实际尺寸  number : 百分数 | 无符号浮点实数.浮点实数值为1.0或百分数为1 ...

  4. LeetCode Binary Tree Upside Down

    原题链接在这里:https://leetcode.com/problems/binary-tree-upside-down/ Given a binary tree where all the rig ...

  5. mouseenter(fn)和mouseleave、mouseover和mouseout的的区别

    $('.box1').mouseenter(function(){//穿入事件mouseenter $(this).css('background','red'); }).mouseleave(fun ...

  6. .NET Framework 4 和 .NET Framework 4 Client Profile

    提出这个问题的背景:在新项目中封装了一个DAL来通过EF框架对数据库操作,但是在项目引用后,每当编译时就会出错!更加诡异的是在Web项目和WCF项目中对此DAL引用时就不会出现此问题.作为一个初学者, ...

  7. Android 利用ListView制作带竖线的多彩表格

    1.listview与GridView 其实Android本身是有表格控件(GridView)的,但是GridView的每一列的宽度被限定为一样宽,有时设计表格时,列宽不可能为同一宽度,所有可以用Li ...

  8. 不连数据库List分页

    package com.jpsycn.kfwggl.common.crawl; import java.util.ArrayList; import java.util.List; public cl ...

  9. 01 viewport

    <meta name="viewport" content="width=device-width,initial-scale=1.0">

  10. Visual Studio 编译纯 C 项目的方法

    项目属性 -> 配置属性 -> C/C++ -> 高级 -> 编译为 -> 选择 `编译为C代码(/TC)` 参考资料: http://stackoverflow.com ...