📄 h20000424-18.htm
字号:
<html><head><script language="JavaScript"> function reset(){ for ( var i=0; i < document.Form1.elements.length; i++ ) { document.Form1.elements[i].options[0].selected=true }}function going(url){ parent.location=url; reset();}</script><style><!--A:link {text-decoration: none; color: #000000; font-family: 宋体}A:visited {text-decoration: none; color: #000000; font-family: 宋体}A:active {text-decoration: none; font-family: 宋体}A:hover {text-decoration: underline:#ffffff; color: #ff0000}body,table {font-size: 9pt; font-family: 宋体}.H1 {font-size: 9pt ; line-height:9pt; align=center}.ourfont {font-size: 9pt ; line-height:9pt; }.ourfont1 {font-size: 9pt ; line-height:9pt; }--></style><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>在DELPHI编程中获取操作系统信息</title></head><body topmargin="0" leftmargin="0"><div align="center"><center><table border="0" cellPadding="0" cellSpacing="0" width="700"><tbody> <tr> <td><p class="content4"><span class="font"><img border="0" height="3" src="../../soft/pix.gif" width="700"></span></td> </tr></tbody></table></center></div><div align="center"><center><table border="0" cellPadding="0" cellSpacing="0" width="700"><tbody> <tr> <td bgColor="#3399ff" width="658"><p class="ourfont"><span class="font"> </span><a style="text-decoration: none; color: rgb(255,255,255)" href="../os/H00705-2.htm">操作系统</a><font color="#FFFFFF"><span class="font"><span> |</span></span></font><a style="color: rgb(255,255,255); text-decoration: none" href="../image/H00705-14.htm">图像处理</a><font color="#FFFFFF"><span>|<span class="font"> </span></span></font><a style="color: rgb(255,255,255); text-decoration: none" href="../autoCAD/H00705-19.htm">辅助设计</a><span class="font"><font color="#FFFFFF"><span> | </span></font></span><a style="color: rgb(255,255,255); text-decoration: none" href="../data/H00705-18.htm">数 据 库</a><span class="font"><font color="#FFFFFF"><span> | </span></font></span><a style="color: rgb(255,255,255); text-decoration: none" href="H00706-1.htm">高级编程</a><span class="font"><font color="#FFFFFF"><span> | </span></font></span><a style="color: rgb(255,255,255); text-decoration: none" href="../netuse/H00705-20.htm">网络应用</a><font color="#FFFFFF"><span><span class="font"> | </span></span></font><a style="color: rgb(255,255,255); text-decoration: none" href="../webpage/H00705-21.htm">网页制作</a><font color="#FFFFFF"><span><span class="font"> |</span></span></font> <a style="color: rgb(255,255,255); text-decoration: none" href="../technic/H00706-3.htm">技术交流 </a><a style="color: rgb(255,255,255); text-decoration: none" href="http://202.100.13.77/clslyb/default.asp?clsid=jiaoc"><font color="#FFFFFF"><strong>过客留言</strong></font></a></td> <td bgColor="#3399ff" width="32"><p align="center" class="ourfont"><a href="mailto:net@163.sn.cn"><img src="../../soft/email.gif" alt="email.gif (493 字节)" border="0" WIDTH="20" HEIGHT="19"></a></td> </tr></tbody></table></center></div><div align="center"><center><table border="1" cellSpacing="1" width="700" bordercolor="#3399FF"><tbody> <tr> <td align="left" bgColor="#FFFFFF" vAlign="top" width="700" bordercolor="#0000FF" bordercolorlight="#0000FF" bordercolordark="#0000FF"><p class="ourfont"> </p> <p align="center"><b>在DELPHI编程中获取操作系统信息</b></p> <p> </p> <p align="left">我们日常的编程中,常常会去判断用户所使用的操作系统是什么?为什么要这么做,因为:为了使应用程序适应不同的操作系统,能让它运行得更好!如在运行某个应用程序前,应先判断用户所使用的是WIN95/98,还是WIN NT。虽然这两个都是常用的操作系统,但在某些方面是完全不同的,在WIN95/98上运行很好的程序不一定在WIN NT上也运行得很好,所以不同的操作系统应有不同的程序代码以适应不同的需要,也为了使程序运行得更好更稳定。<br> 那怎样才能知道用户使用的操作系统是什么呢?我们可以利用API函数来解决,方法如下:<br> 首先做准备工作,新建工程,在FORM1上放上一个LABEL1(CAPTION为空)与一个BUTTON1(CAPTION为获取操作系统信息),其他属性不变,然后输入以下程序代码:<br> unit GETVER;<br> interface<br> uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls;<br> type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Label1: TLabel;<br> procedure Button1Click(Sender: TObject);<br> private{ Private declarations }<br> public{ Public declarations }<br> end;<br> var Form1: TForm1;<br> implementation {$R *.DFM}<br> procedure TForm1.Button1Click(Sender: TObject); //判断用户操作系统。<br> VAR<br> GETVER:OSVERSIONINFO; //声明所需变量,具体内容请参考API函数说明文件。<br> RET:LONGBOOL;<br> begin<br> GETVER.DWOSVERSIONINFOSIZE:=148;<br> RET:=GETVERSIONEX(GETVER); //调用API函数判断开始<br> IF GETVER.DWPLATFORMID=VER_PLATFORM_WIN32_WINDOWS THEN<br> LABEL1.CAPTION:=′您正使用的操作系统是:WINDOWS95/98′;<br> IF GETVER.DWPLATFORMID=VER_PLATFORM_WIN32_NT THEN<br> LABEL1.CAPTION:=′您正使用的操作系统是:WINDOWS NT′;<br> END;<br> END.<br> 现在请运行一下(按下F9),怎么样!是否成功?<br> 不清楚的地方请查看相应的API函数说明,笔者就不再赘述了!<br> 注:以上程序在中文WINDOWS98,DELPHI4.0 C/S版中调试通过。<br> <b> (上海 季昭君)</b></td> </tr></tbody></table></center></div><hr align="center" SIZE="1" width="700"><p align="center" class="ourfont"><span><span><font color="#000000"> <a style="color: rgb(0,0,0); text-decoration: none" href="../../soft/network/index.htm">互联网络</font><font color="#FFFFFF"> </font></a><font color="#000000">|</span></span><a href="../../soft/system/index.htm" style="color: rgb(0,0,0); text-decoration: none">系统工具</a><span>|<span> <a href="../../soft/tools/index.htm" style="color: rgb(0,0,0); text-decoration: none">实用工具</a> | <a href="../../soft/multimedia/index.htm" style="color: rgb(0,0,0); text-decoration: none">媒体工具</a> | <a href="../../soft/image/index.htm" style="color: rgb(0,0,0); text-decoration: none">图形图像</a> | <a href="../../soft/game/index.htm" style="color: rgb(0,0,0); text-decoration: none">游戏娱乐</a> | </span><a href="../../soft/usesoft/index.htm" style="color: rgb(0,0,0); text-decoration: none">软件<span>使用</a></font><font color="#FFFFFF"> |</font> </span></span></p><hr align="center" SIZE="1" width="700"><font color="#FFE8BB"><p align="center" class="ourfont"></font><font color="#000000"><span><span>© Copyright 2000 </span></span>陕西公用计算机互联网信息中心<span><span> 版权所有 </font></p></span></span><p align="center" class="ourfont"><font color="#000000"><span><span>本站制作维护by <a style="color: rgb(0,0,0)" href="mailto:haiyuan@163.sn.cn">HAIYUAN</a></span></span></font></p><p align="center" class="ourfont"><font color="#000000"><span><span>电话:(029)8371051 8371055 8371049 联系信箱:<a href="mailto:net@163.sn.cn">net@163.sn.cn</a></span></span></font></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -