如何读取本机的硬件配置信息

发布网友

我来回答

3个回答

热心网友

1、获取windows版本信息
可以通过Windows API函数GetVersionEx来获得。
具体程序如下:
Procere Tform1.Button1Click(sender:TObject);
Var
OSVI:OSVERSIONINFO;
begin
OSVI.dwOSversioninfoSize:=Sizeof(OSVERSIONINFO);
GetVersionEx(OSVI);
label1.Caption:=IntToStr(OSVI.dwMinorVersion)+','
+IntToStr(OSVI.dwMinorVersion)+','
+IntToStr(OSVI.dwBuildNumber)+','
+IntToStr(OSVI.dwPlatformId)+','
+OSVI.szCSDVersion;
end;

end.

2、获取CPU信息
可以通过Windows API函数GetSystemInfo来获得有关信息。
具体程序如下:
procere TForm1.Button1Click(Sender: TObject);
Var
SysInfo:SYSTEM_INFO;
begin
GetSystemInfo(Sysinfo);
Edit1.Text:='系统中有'+IntToStr(Sysinfo.dwNumberOfProcessors)+'个CPU'
+',类型为'+IntToStr(Sysinfo.dwProcessorType);
end;

end.

3、获取内存信息
可以通过Windows API函数GlobalMemoryStatus来获得内存信息。
具体程序如下:
procere TForm1.Button1Click(Sender: TObject);
Var
MemInfo:MEMORYSTATUS;
begin
MemInfo.dwLength:=sizeof(MEMORYSTATUS);
GlobalMemoryStatus(MemInfo);
memo1.Lines.Add(IntToStr(MemInfo.dwMemoryLoad)+'%的内存正在使用') ;
memo1.Lines.Add('物理内存共有'+IntToStr(MemInfo.dwTotalPhys)+'字节');
memo1.Lines.Add('可使用的物理内存有'+IntToStr(MemInfo.dwAvailPhys)+'字节');
memo1.Lines.Add('交换文件总大小为'+IntToStr(MemInfo.dwTotalPageFile)+'字节') ;
memo1.Lines.Add('尚可交换文件大小为'+IntToStr(MemInfo.dwAvailPageFile)+'字节');
memo1.Lines.Add('总虚拟内存有'+IntToStr(MemInfo.dwTotalVirtual)+'字节');
memo1.Lines.Add('未用虚拟内存有'+IntToStr(MemInfo.dwAvailVirtual)+'字节');
end;

end.

或用以下代码:
memo1.Text:=IntToStr(MemInfo.dwMemoryLoad)+'%的内存正在使用'+#13#10
+'可使用的物理内存有'+IntToStr(MemInfo.dwAvailPhys)+'字节'+#13#10
+'交换文件总大小为'+IntToStr(MemInfo.dwTotalPageFile)+'字节'+#13#10
+'尚可交换文件大小为'+IntToStr(MemInfo.dwAvailPageFile)+'字节'+#13#10
+'总虚拟内存有'+IntToStr(MemInfo.dwTotalVirtual)+'字节'+#13#10
+'未用虚拟内存有'+IntToStr(MemInfo.dwAvailVirtual)+'字节';
来替代memo1.line.add(…)部分。

4、获取Windows和系统路径
可以通过Windows API函数来获得
具体程序如下:
procere TForm1.Button1Click(Sender: TObject);
Var
SysDir:array[0..128] of char;
begin
GetWindowsDirectory(SysDir,128);
Edit1.Text:='Windows 路径:'+SysDir;
GetSystemDirectory(SysDir,128);
Edit1.Text:=Edit1.Text+'; 系统路径:'+SysDir;
end;

end.
其中,笔者通过更改数列的值:发现其中的128可更改为人以不小于16的的数值,若小于或等于16均出现异常(笔者的操作系统为Windows2000)。读者朋友不妨试试。

5、获取用户注册信息
我们都知道,一般在软件安装过程中,它都会提示用户,要求输入系列号或产品号和用户的一些注册信息(用户的公司名称、用户名等)以及安装的目录和路径等。
通过以下代码可查看用户注册信息:
procere TForm1.Button1Click(Sender: TObject);
Var
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_LOCAL_MACHINE;
Reg.OpenKey('Software\Microsoft\Windows NT\CurrentVersion',False);
Edit1.Text:='当前路径:'+Reg.CurrentPath;
Edit2.Text:='产品系列号:'+Reg.ReadString('ProctId');
Edit3.Text:='产品名:'+Reg.ReadString('ProctName');
Edit4.Text:='注册公司名称:'+Reg.ReadString('RegisteredOrganization');
Edit5.Text:='用户名:'+Reg.ReadString('RegisteredOwner');
Edit6.Text:='软件类型:'+Reg.ReadString('SoftwareType');
Reg.CloseKey;
Reg.Free;
end;

end.
注意:在程序编译之前,必须在USES语句下添加registry单元。

6、关闭Widows
可以通过Windows API函数ExitWindowsEx来关闭Widows。
procere TForm1.Button1Click(Sender: TObject);
begin
if RadioButton1.Checked=true then
ExitWindowsEx(EWX_LOGOFF,0) //以其他用户身份登录
else if RadioButton2.Checked=true then
ExitWindowsEx(EWX_SHUTDOWN,1) //安全关机
else if RadioButton3.Checked=true then
ExitWindowsEx(EWX_REBOOT,2) //重新启动计算机
else if RadioButton4.Checked=true then
ExitWindowsEx(EWX_FORCE,4) //强行关机
else if RadioButton5.Checked=true then
ExitWindowsEx(EWX_POWEROFF,8); //关闭系统并关闭电源

end;

end.

热心网友

以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI' 2>nul 3>nul&cls&@echo off
'&rem 获取本机系统及硬件配置信息
'&set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
'&title %#% +%$%%$%/%@% %z%
'&cd /d "%~dp0"
'&set "outfile=xxx.txt"
'&cscript -nologo -e:vbscript "%~f0"
'&echo;%#% +%$%%$%/%@% %z%
'&pause&exit

On Error Resume Next
Set fso=CreateObject("Scripting.Filesystemobject")
Set ws=CreateObject("WScript.Shell")
Set wmi=GetObject("winmgmts:\\.\root\cimv2")
   
WSH.echo "---------------系统-------------"
Set query=wmi.ExecQuery("Select * from Win32_ComputerSystem")
For each item in query
    WSH.echo "当前用户=" & item.UserName
    WSH.echo "工作组=" & item.Workgroup
    WSH.echo "域=" & item.Domain
    WSH.echo "计算机名=" & item.Name
    WSH.echo "系统类型=" & item.SystemType
Next
   
Set query=wmi.ExecQuery("Select * from Win32_OperatingSystem")
For each item in query
    WSH.echo "系统=" & item.Caption & "[" & item.Version & "]"
    WSH.echo "初始安装日期=" & item.InstallDate
    visiblemem=item.TotalVisibleMemorySize
    virtualmem=item.TotalVirtualMemorySize
Next
   
Set query=wmi.ExecQuery("Select * from Win32_ComputerSystemProct")
For each item in query
    WSH.echo "制造商=" & item.Vendor
    WSH.echo "型号=" & item.Name
Next
   
WSH.echo "---------------主板BIOS-------------"
Set query=wmi.ExecQuery("Select * from Win32_BaseBoard")
For each item in query
    WSH.echo "制造商=" & item.Manufacturer
    WSH.echo "序列号=" & item.SerialNumber
Next
  
Set query=wmi.ExecQuery("Select * from Win32_BIOS")
For each item in query
    WSH.echo "名称=" & item.Name
    WSH.echo "bios制造商=" & item.Manufacturer
    WSH.echo "发布日期=" & item.ReleaseDate
    WSH.echo "版本=" & item.SMBIOSBIOSVersion
Next
   
WSH.echo "---------------CPU-------------"
Set query=wmi.ExecQuery("Select * from WIN32_PROCESSOR")
For each item in query
    WSH.echo "序号=" & item.DeviceID
    WSH.echo "名称=" & item.Name
    WSH.echo "核心=" & item.NumberOfCores
    WSH.echo "线程=" & item.NumberOfLogicalProcessors
Next
   
WSH.echo "---------------内存-------------"
WSH.echo "总物理内存=" & FormatNumber(visiblemem/1048576,2,True) & " GB"
WSH.echo "总虚拟内存=" & FormatNumber(virtualmem/1048576,2,True) & " GB"
Set query=wmi.ExecQuery("Select * from Win32_PhysicalMemory")
For each item in query
    WSH.echo "序号=" & item.Tag
    WSH.echo "容量=" & FormatSize(item.Capacity)
    WSH.echo "主频=" & item.Speed
    WSH.echo "制造商=" & item.Manufacturer
Next
   
WSH.echo "--------------硬盘-------------"
Set query=wmi.ExecQuery("Select * from Win32_DiskDrive")
For each item in query
    WSH.echo "名称=" & item.Caption
    WSH.echo "接口=" & item.InterfaceType
    WSH.echo "容量=" & FormatSize(item.Size)
    WSH.echo "分区数=" & item.Partitions
Next
   
Set query=wmi.ExecQuery("Select * from Win32_LogicalDisk Where DriveType=3 or DriveType=2")
For each item in query
    WSH.echo item.Caption & Chr(9) & item.FileSystem & Chr(9) & FormatSize(item.Size) & Chr(9) & FormatSize(item.FreeSpace)
Next
   
WSH.echo "--------------网卡-------------"
Set query=wmi.ExecQuery("Select * from Win32_NetworkAdapter Where NetConnectionID !=null and not Name like '%Virtual%'")
For each item in query
    WSH.echo "名称=" & item.Name
    WSH.echo "连接名=" & item.NetConnectionID
    WSH.echo "MAC=" & item.MACAddress
    Set query2=wmi.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where Index=" & item.Index)
    For each item2 in query2
        If typeName(item2.IPAddress) <> "Null" Then
            WSH.echo "IP=" & item2.IPAddress(0)
        End If
    Next
Next
   
WSH.echo "--------------显示-------------"
Set query=wmi.ExecQuery("Select * from Win32_VideoController")
For each item in query
    WSH.echo "名称=" & item.Name
    WSH.echo "显存=" & FormatSize(Abs(item.AdapterRAM))
    WSH.echo "当前刷新率=" & item.CurrentRefreshRate
    WSH.echo "水平分辨率=" & item.CurrentHorizontalResolution
    WSH.echo "垂直分辨率=" & item.CurrentVerticalResolution
Next
   
WSH.echo "--------------声卡-------------"
Set query=wmi.ExecQuery("Select * from WIN32_SoundDevice")
For each item in query
    WSH.echo item.Name
Next
   
WSH.echo "--------------打印机-------------"
Set query=wmi.ExecQuery("Select * from Win32_Printer")
For each item in query
    If item.Default =True Then
        WSH.echo item.Name & "(默认)"
    Else
        WSH.echo item.Name
    End If
Next
   
Function FormatSize(byVal t)
    If t >= 1099511627776 Then
        FormatSize = FormatNumber(t/1099511627776, 2, true) & " TB"
    ElseIf t >= 1073741824 Then
        FormatSize = FormatNumber(t/1073741824, 2, true) & " GB"
    ElseIf t >= 1048576 Then
        FormatSize = FormatNumber(t/1048576, 2, true) & " MB"
    ElseIf t >= 1024 Then
        FormatSize = FormatNumber(t/1024, 2, true) & " KB"
    Else
        FormatSize = t & " B"    
    End If
End Function

热心网友

下载安装一个“鲁大师”。可以对你的硬件信息进行检测,还有温度,硬件品牌之类的信息都有

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com