获取CPUID等
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等的更多相关文章
- java支持跨平台获取cpuid、主板id、硬盘id、mac地址 (兼容windows、Linux)
windows: package cn.net.comsys.helper.system.info; import java.io.BufferedReader; import java.io.F ...
- C#获取CPUID(MD5输出),网卡ID,主DNS,备用DNS
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...
- C#-获取CPUID
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...
- 获取硬件信息的delphi源码CPUID、操作系统、Mac物理地址、计算机名称、IP地址、用户名
{-----------------------------------------------------------------------------作者:sushengmiyan 2013.0 ...
- C# 获取计算机信息
//C#获取当前计算机的系统信息 //系统标识符和版本号 string strSystem = Environment.OSVersion.ToString(); //获取映射到进程上下文的物理内存量 ...
- WMI 获取硬件信息的封装函数与获取联想台式机的出厂编号方法
原文:WMI 获取硬件信息的封装函数与获取联想台式机的出厂编号方法 今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都是可以提取出来的,就自己把那些公共部分提出出来,以后如果要获取 某部分的 ...
- 本地服务器硬件信息获取指令wmic
获取BIOS序列号 wmic bios list full | find "SerialNumber" SerialNumber=P50168VB 获取CPUID(WIN32_PR ...
- 获取本地机器的特征码IP MAC
using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Ma ...
- c#中如何获取本机MAC地址、IP地址、硬盘ID、CPU序列号等系统信息
我们在利用C#开发桌面程序(Winform)程序的时候,经常需要获取一些跟系统相关的信息,例如用户名.MAC地址.IP地址.硬盘ID.CPU序列号.系统名称.物理内存等. 首先需要引入命名空间: us ...
随机推荐
- SQL Server select 将类型相同的行合并
select Category from(select distinct Category from T_Detail where CREATED_BY= @CREATED_BY AND Record ...
- 使用Aspose.Cell控件实现Excel高难度报表的生成(二)
继续在上篇<使用Aspose.Cell控件实现Excel高难度报表的生成(一)>随笔基础上,研究探讨基于模板的Aspose.cell报表实现,其中提到了下面两种报表的界面,如下所示: 或者 ...
- android中用Spannable在TextView中设置超链接、颜色、字体
昨晚研读 ApiDemo 源码至 com.example.android.apis.text.Link 类.首先,看一下其运行效果: 要给 TextView 加上效果,方式主要有几种: 第一种,自动 ...
- Java Collections的排序之二
package test.list; import java.util.ArrayList; import java.util.Collections; import java.util.HashSe ...
- 关于Eclipse的unsupported major minor version 51.0 错误
把别人的工程 拿来运行报上述错误 是因为工程版本不对 解决办法:新建工程 把现有的代码或资源文件 拷到新建工程里
- Java基础之读文件——使用输入流读取二进制文件(StreamInputFromFile)
控制台程序,读取Java基础之读文件部分(StreamOutputToFile)写入的50个fibonacci数字. import java.nio.file.*; import java.nio.* ...
- linux:/etc/rc.local 不能自动启动问题
前段时间安装LNMP环境,配置/etc/rc.local的时候配置了启动mysql.nginx.php以及关闭防火墙,可结果重启了七八次还是自启动不了后来终于找到原因了 看下图: /etc/rc.lo ...
- 与PostgreSQL相关的工具
Pentaho Data Integration(kettle):一个优秀的抽取.转换.加载(Extract Transform and Load,ETL)工具 Pentaho Report Ser ...
- C# 问题解决思路--《数组bytes未定义》,ASP.NET页面加载顺序
好久没写博客了,废话不多说,直接说问题. 问题发生情况,首先这个是老项目,然后我是第一次修改.当我解决了各种引用,数据库配置之后等类似的问题,我启动的项目的时候,无任何问题,但是当我点击页面的按钮的时 ...
- 也不知怎么了LVS.SH找不到,网上搜了一篇环境搭配CENTOS下面的高可用 参考
系统环境: ************************************************************ 两台服务器都装了 CentOS-5.2-x86_64 系统 Vir ...