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. php保存远程文件到本地的方法

    用到了ob_start();<?php header("Content-type:text/html charset=utf-8"); if(!empty($_POST['p ...

  2. 配置SQL Server Session方法

    以下过程是在Win 2003 SP2 + IIS 6.0, ASP.NET 2.0, SQL Server 2005下进行的. 1. 安装Session数据库到Framework目录 C:\WINDO ...

  3. BIND_MISMATCH导致过多VERSION COUNT的问题

    并不是用了绑定变量就一定都会游标共享,下面我们介绍的就是一种例子.BIND_MISMATCH导致VERSION COUNT过多的原因解释: This is due to the bind buffer ...

  4. Scanner类的使用

    Scanner类的使用 (接受键盘输入) java.util.Scanner是Java5的新特征,主要功能是简化文本扫描.这个类最实用的地方表现在获取控制台输入,其他的功能都很鸡肋,尽管Java AP ...

  5. Maven 介绍

    1.maven的用途maven是一个项目构建和管理的工具,提供了帮助管理 构建.文档.报告.依赖.scms.发布.分发的方法.可以方便的编译代码.进行依赖管理.管理二进制库等等.maven的好处在于可 ...

  6. boost 1.57.0安装

    一. PC编译安装boost boost是C++的准标准库,其有两种安装方法. 1. ubuntu下,通过sudo apt-get install libboost-all-dev. 2. 通过源码包 ...

  7. NETBEANS + XDEBUG + IIS PHP 代码 调试 DEBUG

    参考: http://domainwebcenter.com/?p=936 http://www.sitepoint.com/debugging-and-profiling-php-with-xdeb ...

  8. Strawberry Perl CPAN Install Module 安装 Module 方法

    我在 Windows 上用的是 Strawberry Perl. 安装好 Strawberry Perl 之后, 打开 CMD, 输入 CPAN <Module_Name> 即可安装你想要 ...

  9. 阿里与腾讯“智慧城市”的O2O谁更强?(分享)

    成都亿合科技:本月22日蚂蚁金服联合新浪微博宣布“智慧城市”战略,用户可通过新浪微博.手机淘宝.支付宝三大客户端完成医疗.市政缴费以及相关信息查询工作,首批入驻城市有上海.太原.深圳.青岛等12个城市 ...

  10. Oracle 12C -- 使用seed PDB创建新的pdb

    $ sqlplus '/as sysdba' SQL*Plus: Release Production on Tue Jun :: Copyright (c) , , Oracle. All righ ...