获得 CPU 的 ID.function CPUID: TCpuInfo;
var
CPUInfo: TCpuInfo;
HiVal: Cardinal;
TimesToExecute, CurrentLoop: Byte;
begin
asm
MOV [CPUInfo.HasInstruction], 0
MOV [CPUInfo.HasExtendedInfo], 0
MOV [CPUInfo.HasCacheInfo], 0
MOV [CPUInfo.PType], 0
MOV [CPUInfo.Model], 0
MOV [CPUInfo.Stepping], 0
MOV [CPUInfo.Features], 0
MOV [CPUInfo.FrequencyInfo.RawFreq], 0
MOV [CPUInfo.FrequencyInfo.NormFreq], 0
MOV [CPUInfo.FrequencyInfo.InCycles], 0
MOV [CPUInfo.FrequencyInfo.ExTicks], 0 PUSH EAX
PUSH EBP
PUSH EBX
PUSH ECX
PUSH EDI
PUSH EDX
PUSH ESI @@Check80486:
MOV [CPUInfo.Family], 4
PUSHFD
POP EAX
MOV ECX, EAX
XOR EAX, 200000H
PUSH EAX
POPFD
PUSHFD
POP EAX
XOR EAX, ECX
JE @@DoneCpuType @@HasCPUIDInstruction:
MOV [CPUInfo.HasInstruction], 1
MOV EAX, 0
DB 0FH
DB 0A2H MOV HiVal, EAX
MOV DWORD PTR [CPUInfo.VendorIDString], EBX
MOV DWORD PTR [CPUInfo.VendorIDString + 4], EDX
MOV DWORD PTR [CPUInfo.VendorIDString + 8], ECX @@CheckIntel:
CMP DWORD PTR [CPUInfo.VendorIDString], 'uneG'
JNE @@CheckAMD
CMP DWORD PTR [CPUInfo.VendorIDString + 4], 'Ieni'
JNE @@CheckAMD
CMP DWORD PTR [CPUInfo.VendorIDString + 8], 'letn'
JNE @@CheckAMD
MOV [CPUInfo.CpuType], CPU_TYPE_INTEL
JMP @@StandardFunctions @@CheckAMD:
CMP DWORD PTR [CPUInfo.VendorIDString], 'htuA'
JNE @@CheckCitrix
CMP DWORD PTR [CPUInfo.VendorIDString + 4], 'itne'
JNE @@CheckCitrix
CMP DWORD PTR [CPUInfo.VendorIDString + 8], 'DMAc'
JNE @@CheckCitrix
MOV [CPUInfo.CpuType], CPU_TYPE_AMD
JMP @@CheckAMDExtended @@CheckCitrix:
CMP DWORD PTR [CPUInfo.VendorIDString], 'iryC'
JNE @@StandardFunctions
CMP DWORD PTR [CPUInfo.VendorIDString + 4], 'snIx'
JNE @@StandardFunctions
CMP DWORD PTR [CPUInfo.VendorIDString + 8], 'daet'
JNE @@StandardFunctions
MOV [CPUInfo.CpuType], CPU_TYPE_CYRIX
JMP @@CheckCitrixExtended
var
CPUInfo: TCpuInfo;
HiVal: Cardinal;
TimesToExecute, CurrentLoop: Byte;
begin
asm
MOV [CPUInfo.HasInstruction], 0
MOV [CPUInfo.HasExtendedInfo], 0
MOV [CPUInfo.HasCacheInfo], 0
MOV [CPUInfo.PType], 0
MOV [CPUInfo.Model], 0
MOV [CPUInfo.Stepping], 0
MOV [CPUInfo.Features], 0
MOV [CPUInfo.FrequencyInfo.RawFreq], 0
MOV [CPUInfo.FrequencyInfo.NormFreq], 0
MOV [CPUInfo.FrequencyInfo.InCycles], 0
MOV [CPUInfo.FrequencyInfo.ExTicks], 0 PUSH EAX
PUSH EBP
PUSH EBX
PUSH ECX
PUSH EDI
PUSH EDX
PUSH ESI @@Check80486:
MOV [CPUInfo.Family], 4
PUSHFD
POP EAX
MOV ECX, EAX
XOR EAX, 200000H
PUSH EAX
POPFD
PUSHFD
POP EAX
XOR EAX, ECX
JE @@DoneCpuType @@HasCPUIDInstruction:
MOV [CPUInfo.HasInstruction], 1
MOV EAX, 0
DB 0FH
DB 0A2H MOV HiVal, EAX
MOV DWORD PTR [CPUInfo.VendorIDString], EBX
MOV DWORD PTR [CPUInfo.VendorIDString + 4], EDX
MOV DWORD PTR [CPUInfo.VendorIDString + 8], ECX @@CheckIntel:
CMP DWORD PTR [CPUInfo.VendorIDString], 'uneG'
JNE @@CheckAMD
CMP DWORD PTR [CPUInfo.VendorIDString + 4], 'Ieni'
JNE @@CheckAMD
CMP DWORD PTR [CPUInfo.VendorIDString + 8], 'letn'
JNE @@CheckAMD
MOV [CPUInfo.CpuType], CPU_TYPE_INTEL
JMP @@StandardFunctions @@CheckAMD:
CMP DWORD PTR [CPUInfo.VendorIDString], 'htuA'
JNE @@CheckCitrix
CMP DWORD PTR [CPUInfo.VendorIDString + 4], 'itne'
JNE @@CheckCitrix
CMP DWORD PTR [CPUInfo.VendorIDString + 8], 'DMAc'
JNE @@CheckCitrix
MOV [CPUInfo.CpuType], CPU_TYPE_AMD
JMP @@CheckAMDExtended @@CheckCitrix:
CMP DWORD PTR [CPUInfo.VendorIDString], 'iryC'
JNE @@StandardFunctions
CMP DWORD PTR [CPUInfo.VendorIDString + 4], 'snIx'
JNE @@StandardFunctions
CMP DWORD PTR [CPUInfo.VendorIDString + 8], 'daet'
JNE @@StandardFunctions
MOV [CPUInfo.CpuType], CPU_TYPE_CYRIX
JMP @@CheckCitrixExtended
解决方案 »
- 三层架构中 频繁的访问和释放数据库 如何优化和提高效率
- 使用Remobject SDK控件,在windows 2008下无法访问服务端
- delphi6好还是7好
- exe中的res,想用别的res替换,用什么软件可以做到!?
- 怎樣pan別oldvalue和newvalue的数据是一样﹐
- 求助!
- 一台电脑可以连接两台针式打印机(EPSON LQ-300K)吗?
- 有没有透明的控件如BitBtn,Label等?
- ???请问各位大侠,文本数据记录如何转换为数据库的表形式
- 请问Delphi中有没有象c语言中的对二进制位操作?有没有用结构体定义一个整形的二进制位?
- 十万火急,高手求助
- 我的天,delphi程序员找工作太难了,没人要呀。在深圳转了一个月无一家公司招聘我。
var
systeminfo: SYSTEM_INFO;
memory: MEMORYSTATUS;
sector,byte,cluster,free: DWORD;
freespace,totalspace: longint;
CDtype: UINT;
name: CHAR;
drvname: string;
volname,filesysname: PCHAR;
sno,maxl,fileflag: DWORD;
begin
Memo1.Lines.Clear();
//获得CPU型号
GetSystemInfo(systeminfo);
Memo1.Lines.Add('您的CPU类型是:' + inttostr(systeminfo.dwProcessorType)); //获得内存状态
memory.dwLength := sizeof(memory); //初始化
GlobalMemoryStatus(memory);
Memo1.Lines.Add('您的物理内存是(' + inttostr(integer(memory.dwTotalPhys div 1024 div 1024)) + 'MB)。');
Memo1.Lines.Add('其中可用内存是(' + inttostr(integer(memory.dwTotalPhys div 1024)) + 'KB)。'); //获得C盘可用空间
GetDiskFreeSpace('C:', LPDWORD(@sector)^, LPDWORD(@byte)^, LPDWORD(@free)^, LPDWORD(@cluster)^); //获得返回参数
totalspace := cluster * byte * sector div 1024 div 1024; //计算总容量
freespace := free * byte * sector div 1024 div 1024; //计算可用空间
Memo1.Lines.Add('C盘总空间(' + inttostr(integer(totalspace)) + 'MB)。');
Memo1.Lines.Add('C盘可用空间(' + inttostr(integer(freespace)) + 'MB)。'); //检测CD-ROM,是否有光盘
GetMem(volname, 255);
GetMem(filesysname, 100);
for name :='C' to 'Z' do//循环检测A~Z
begin
drvname := name + ':';
CDtype := GetDriveType(PCHAR(@drvname[1])); //获得磁盘类型
if (CDtype = DRIVE_CDROM) then
begin
Memo1.Lines.Add('您的光驱盘符为[' + drvname + ']');
volname^ := Chr(0);
filesysname^ := Chr(0);
if ( not (GetVolumeInformation(PCHAR(@drvname[1]), volname, 250, LPDWORD(@sno), LPDWORD(@maxl)^, LPDWORD(@fileflag)^, filesysname,100))) then
Memo1.Lines.Add(drvname + '驱中没有发现光盘') //如果返回值为假
else //如果返回值为真
begin
Memo1.Lines.Add (drvname + '驱中光盘卷标为: [' + String(volname) + ']');
Memo1.Lines.Add (drvname + '驱中光盘序号为: [' + inttostr(sno) + ']');
end;
end;
end;
FreeMem(volname);
FreeMem(filesysname)
end;
好像是干这个用的。说明如下:
GetAdaptersInfo
The GetAdaptersInfo function retrieves adapter information for the local computer. DWORD GetAdaptersInfo(
PIP_ADAPTER_INFO pAdapterInfo, // buffer to receive data
PULONG pOutBufLen // size of data returned
);
Parameters
pAdapterInfo
[out] Pointer to a buffer that, , receives a linked list of IP_ADAPTER_INFO structures.
pOutBufLen
[in] Pointer to a ULONG variable that specifies the size of the buffer pointed to by the pAdapterInfo parameter. If this size is insufficient to hold the adapter information, GetAdaptersInfo fills in this variable with the required size, and returns an error code of ERROR_BUFFER_OVERFLOW.
Return Values
If the function succeeds, the return value is ERROR_SUCCESS. If the function fails, the return value is one of the following error codes. Value Meaning
ERROR_BUFFER_OVERFLOW The buffer size indicated by the pOutBufLen parameter is too small to hold the adapter information. The pOutBufLen parameter points to the required size.
ERROR_INVALID_PARAMETER The pOutBufLen parameter is NULL, or the calling process does not have read/write access to the memory pointed to by pOutBufLen, or the calling process does not have write access to the memory pointed to by the pAdapterInfo parameter.
ERROR_NO_DATA No adapter information exists for the local computer.
ERROR_NOT_SUPPORTED GetAdaptersInfo is not supported by the operating system running on the local computer.
Other If the function fails, use FormatMessage to obtain the message string for the returned error.
Requirements
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 98.
Header: Declared in Iphlpapi.h.//没有
Library: Use Iphlpapi.lib.//没有 IP_ADAPTER_INFO
The IP_ADAPTER_INFO structure contains information about a particular network adapter on the local computer. typedef struct _IP_ADAPTER_INFO {
struct _IP_ADAPTER_INFO* Next;
DWORD ComboIndex;
char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
UINT AddressLength;
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
DWORD Index;
UINT Type;
UINT DhcpEnabled;
PIP_ADDR_STRING CurrentIpAddress;
IP_ADDR_STRING IpAddressList;
IP_ADDR_STRING GatewayList;
IP_ADDR_STRING DhcpServer;
BOOL HaveWins;
IP_ADDR_STRING PrimaryWinsServer;
IP_ADDR_STRING SecondaryWinsServer;
time_t LeaseObtained;
time_t LeaseExpires;
} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
Members
Next
Pointer to the next adapter in the linked list of adapters.
ComboIndex
This member is unused.
AdapterName[MAX_ADAPTER_NAME_LENGTH + 4]
Specifies the name of the adapter.
Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4]
Specifies a description for the adapter.
AddressLength
Specifies the length of the hardware address for the adapter.
Address[MAX_ADAPTER_ADDRESS_LENGTH]
Specifies the hardware address for the adapter. //这个是不是你想要的?
Index
Specifies the adapter index.
Type
Specifies the adapter type.
DhcpEnabled
Specifies whether dynamic host configuration protocol (DHCP) is enabled for this adapter.
CurrentIpAddress
Specifies the current IP address for this adapter.
IpAddressList
Specifies the list of IP addresses associated with this adapter.
GatewayList
Specifies the IP address of the default gateway for this adapter.
DhcpServer
Specifies the IP address of the DHCP server for this adapter.
HaveWins
Specifies whether this adapter uses Windows Internet Name Service (WINS).
PrimaryWinsServer
Specifies the IP address of the primary WINS server.
SecondaryWinsServer
Specifies the IP address of the secondary WINS server.
LeaseObtained
Specifies the time when the current DHCP lease was obtained.
LeaseExpires
Specifies the time when the current DHCP lease will expire.
Requirements
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 98.
Header: Declared in Iptypes.h.
email: [email protected]或者QQ:4264362
[email protected]