1、获取windows版本信息

可以通过Windows API函数GetVersionEx来获得。

具体程序如下:

Procedure 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来获得有关信息。

具体程序如下:

procedure 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来获得内存信息。

具体程序如下:

procedure 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函数来获得

具体程序如下:

procedure 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、获取用户注册信息

我们都知道,一般在软件安装过程中,它都会提示用户,要求输入系列号或产品号和用户的一些注册信息(用户的公司名称、用户名等)以及安装的目录和路径等。

通过以下代码可查看用户注册信息:

procedure 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('ProductId');
Edit3.Text:='产品名:'+Reg.ReadString('ProductName');
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。

procedure 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.

(T113)

几个获取Windows系统信息的Delphi程序的更多相关文章

  1. 获取windows系统信息

    在应用程序中,有时需要在界面中显示计算机的硬件信息和进程信息.在.Net中提供了可以查询信息的类.Management类,在程序中添加应用后进行使用. 1 属性 类似的属性介绍可见下面: 属性介绍 根 ...

  2. Python WMI获取Windows系统信息

    #!/usr/bin/env python # -*- coding: utf-8 -*- #http://www.cnblogs.com/liu-ke/ import wmi import os i ...

  3. Python WMI获取Windows系统信息 监控系统

    #!/usr/bin/env python # -*- coding: utf-8 -*- #http://www.cnblogs.com/liu-ke/ import wmi import os i ...

  4. 获取CPU序列号的Delphi程序

    Unit CPUid; Interface Type TCpuType = (cpu8086, cpu286, cpu386, cpu486, cpuPentium); Function CpuTyp ...

  5. C#获取WINDOWS系统信息

    需引用System.Management命名空间, 具体代码如下: public class SysProp { public SysProp() { ManagementObjectSearcher ...

  6. python使用wmi模块获取windows下的系统信息监控系统-乾颐堂

    Python用WMI模块获取Windows系统的硬件信息:硬盘分区.使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息. 本文实例讲述了python使用wmi模块获取w ...

  7. 获取windows 操作系统下的硬件或操作系统信息等

    奇怪的工作,制作的是一款办公应用软件,领导却要求我统计用户计算机的物理信息,什么CPU的型号.核心数,什么内存信息等各种乱七八糟的用户信息.我想问,现在用户的信息就这么没有隐私性了么?想获取就获取传递 ...

  8. 让delphi程序不受WINDOWS日期格式的影响

    http://www.cnblogs.com/hnxxcxg/archive/2013/01/30/2882672.html 如果WINDOWS系统的短日期格式为“yyyy/m/d”,执行下面的代码会 ...

  9. 让delphi程序不受WINDOWS日期格式的影响(使用SetLocaleInfo函数和Application.UpdateFormatSettings)

    如果WINDOWS系统的短日期格式为“yyyy/m/d”,执行下面的代码会报错:2013-01-29 00:00:00不是合法的日期procedure TFrmQuerySale.FormShow(S ...

随机推荐

  1. JfreeCHart 异常:Chart image not found

    http://bbs.justep.com/thread-54775-1-1.html java.lang.IllegalArgumentException: Width (0) and height ...

  2. Byte数组和Int的互相转换

    public static int bytesToInt(byte[] bytes) { int addr = bytes[0] & 0xFF; addr |= ((bytes[1] < ...

  3. SDAU课程练习--problemO(1014)

    题目描述 Before bridges were common, ferries were used to transport cars across rivers. River ferries, u ...

  4. localStorage、sessionStorages 使用

    html5中的Web Storage包括了两种存储方式:sessionStorage和localStorage.sessionStorage用于本地存储一个会话(session)中的数据,这些数据只有 ...

  5. USACO 1.3.1

    题目链接:USACO 1.3.1 简单的贪心,将cent从小到大排序. /* ID:wang9621 PROG:milk LANG:C++ */ #include <iostream> # ...

  6. Employment Planning DP

    Employment Planning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  7. Windows Server 2012如果打开网页慢下载快的话

    原来Windows server 2012默认打开了ECN功能(貌似从Windows server  2008之后都默认打开),个人操作系统却没有打开,而办公室网络的确拥塞不小,造成了这种效果.好了, ...

  8. Python+Selenium WebDriver API:浏览器及元素的常用函数及变量整理总结

    由于网页自动化要操作浏览器以及浏览器页面元素,这里笔者就将浏览器及页面元素常用的函数及变量整理总结一下,以供读者在编写网页自动化测试时查阅. from selenium import webdrive ...

  9. JQuery实现仿腾讯的固定导航栏

    1.描述 窗口滚动一定高度之后才让导航栏固定 2.要点 浏览器滚动的事件:$(window).scroll(functiuon(){ 文档滚过的高度: $(doucment).scrollTop(); ...

  10. Javascript Jquery 中的数组定义与操作_子木玲_新浪博客

    body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...