设为首页】 【加入收藏】 【网站地图】 【商品折扣
娱乐一生 娱乐明星
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
首页  |  java  |  .NET  |  C/C++  |  网页技术  |  php  |  asp  |  delphi  |  VC  |  VB开发  |  游戏开发  |  软件工程  |  Power Builder  |  Linux开发  |  Windows开发技巧
当前位置:首页 >> delphi >> 获得Windows的版本信息_Delphi教程_src119.com

获得Windows的版本信息_Delphi教程_src119.com -

  最近写控件,因为想加入版本信息,而通常大多数情况下,几乎所有的公司或个人都会在自己软件的版本信息里提及Windows与内存信息。
  参考MSDN的范例,我把它写成个函数了。由于Delphi6不提供OSVERSIONINFOEX结构(我没用过delphi7,8,2005等,不知道是否开始提供这个结构了),所以只好自己定义一个。为了不会受到有的版本里已经提供这个结构的影响,也不影响别的什么地方,直接把它定义到函数内部了。

函数:(2000,XP下测试通过,有其它版本的兄弟可以测试一下,有问题,发消息给我)

function GetVersionInfo(var  roduct, SVersion,  ervicePack :String):BOOL;
type
  _OSVERSIONINFOEXA = record
  dwOSVersionInfoSize: DWORD;
  dwMajorVersion: DWORD;
  dwMinorVersion: DWORD;
  dwBuildNumber: DWORD;
  dwPlatformId: DWORD;
  szCSDVersion: array[0..127] of A iChar;
  wServicePackMajor: WORD;
  wServicePackMinor: WORD;
  wSuiteMask: Word;
  wProductType: Byte;
  wReserved: Byte;
  end;
  _OSVERSIONINFOEXW = record
  dwOSVersionInfoSize: DWORD;
  dwMajorVersion: DWORD;
  dwMinorVersion: DWORD;
  dwBuildNumber: DWORD;
  dwPlatformId: DWORD;
  szCSDVersion: array[0..127] of WideChar;
  wServicePackMajor: WORD;
  wServicePackMinor: WORD;
  wSuiteMask: Word;
  wProductType: Byte;
  wReserved: Byte;
  end;
  { this record only su ort Windows 4.0  6 and latter , Windows 2000 ,XP, 2003 }
  OSVERSIONINFOEXA = _OSVERSIONINFOEXA;
  OSVERSIONINFOEXW = _OSVERSIONINFOEXW;
  OSVERSIONINFOEX = OSVERSIONINFOEXA;
co t
  VER_PLATFORM_WIN32_CE = 3;
  { wProductType defines }
  VER_NT_WORKSTATIO  = 1;
  VER_NT_DOMAIN_CONTROLLER  = 2;
  VER_NT_SERVER  = 3;
  { wSuiteMask defines }
  VER_SUITE_SMALLBUSINE  = $0001;
  VER_SUITE_ENTERPRISE  = $0002;
  VER_SUITE_BACKOFFICE  = $0004;
  VER_SUITE_TERMINAL  = $0010;
  VER_SUITE_SMALLBUSINE _RESTRICTED  = $0020;
  VER_SUITE_DATACENTER  = $0080;
  VER_SUITE_PERSONAL  = $0200;
  VER_SUITE_BLADE  = $0400;
  VER_SUITE_SECURITY_A LIANCE  = $1000;
var
  Info: OSVERSIONINFOEX;
  bEx: BOOL;
begin
  Result := False;
  FillChar(Info, SizeOf(OSVERSIONINFOEX), 0);
  Info.dwOSVersionInfoSize := SizeOf(OSVERSIONINFOEX);
  bEx := GetVersionEx(POSVERSIONINFO(@Info)^);
  if not bEx then
  begin
  Info.dwOSVersionInfoSize := SizeOf(OSVERSIONINFO);
  if not GetVersionEx(POSVERSIONINFO(@Info)^) then Exit;
  end;
  with Info do
  begin
  SVersion := IntToStr(dwMajorVersion) + '.' + IntToStr(dwMinorVersion)
  + '.' + IntToStr(dwBuildNumber and $0000FFFF);
   roduct := 'Microsoft Windows unknown';
  case Info.dwPlatformId of
  VER_PLATFORM_WIN32s: { Windows 3.1 and earliest }
   roduct := 'Microsoft Win32s';
  VER_PLATFORM_WIN32_WINDOWS:
  case dwMajorVersion of
  4: { Windows95,98,ME }
  case dwMinorVersion of
  0:
  if szCSDVersion[1] in ['B', 'C'] then
  begin
   roduct := 'Microsoft Windows 95 OSR2';
  SVersion := SVersion + szCSDVersion[1];
  end
  else
   roduct := 'Microsoft Windows 95';
  10:
  if szCSDVersion[1] = 'A' then
  begin
   roduct := 'Microsoft Windows 98 SE';
  SVersion := SVersion + szCSDVersion[1];
  end
  else
   roduct := 'Microsoft Window  98';
  90:
   roduct := 'Microsoft Windows Mille ium Edition';
  end;
  end;
  VER_PLATFORM_WIN32_NT:
  begin
   ervicePack := szCSDVersio 
  case dwMajorVersion of
  0..4:
  if bEx then
  begin
  case wProductType of
  VER_NT_WORKSTATION:
   roduct := 'Microsoft Windows NT Workstation 4.0';
  VER_NT_SERVER:
  if wSuiteMask and VER_SUITE_ENTERPRISE < gt; 0 then
   roduct := 'Microsoft Windows NT Advanced Server 4.0'
  else
   roduct := 'Microsoft Windows NT Server 4.0';
  end;
  end
  else  { NT351 and NT4.0  5 earliest}
  with TRegistry.Create do
  try
  RootKey := HKEY_LOCAL_MACHINE;
  if OpenKey('SYSTEM\CurrentControlSet\Control\ProductOptio ', False) then
  begin
  if ReadString('ProductType') = 'WI T' then
   roduct := 'Microsoft Windows NT Workstation ' + SVersion
  else if ReadString('ProductType') = 'LANMA T' then
   roduct := 'Microsoft Windows NT Server ' + SVersion
  else if ReadString('ProductType') = 'LANMA T' then
   roduct := 'Microsoft Windows NT Advanced Server ' + SVersio 
  end;
  finally
  Free;
  end;
  5:
  case dwMinorVersion of
  0:  { Windows 2000 }
  case wProductType of
  VER_NT_WORKSTATION:
   roduct := 'Microsoft Windows 2000 Profe ional';
  VER_NT_SERVER:
  if wSuiteMask and VER_SUITE_DATACENTER < gt; 0 then
   roduct := 'Microsoft Windows 2000 Datacenter Server'
  else if wSuiteMask and VER_SUITE_ENTERPRISE < gt; 0 then
   roduct := 'Microsoft Windows 2000 Advanced Server'
  else
   roduct := 'Microsoft Windows 2000 Server';
  end;
  1: { Windows XP }
  if wSuiteMask and VER_SUITE_PERSONAL < gt; 0 then
   roduct := 'Microsoft Windows Home Edition'
  else
   roduct := 'Microsoft Windows Profe ional';
  2: { Windows Server 2003 }
  if wSuiteMask and VER_SUITE_DATACENTER < gt; 0 then
   roduct := 'Microsoft Windows Server 2003 Datacenter Edition'
  else if wSuiteMask and VER_SUITE_ENTERPRISE < gt; 0 then
   roduct := 'Microsoft Windows Server 2003 Enterprise Edition'
  else if wSuiteMask and VER_SUITE_BLADE < gt; 0 then
   roduct := 'Microsoft Windows Server 2003 Web Edition'
  else
   roduct := 'Microsoft Windows Server 2003 Standard Edition';
  end;
  end;
  end;
  VER_PLATFORM_WIN32_CE: { Windows CE }
   roduct :=  roduct + ' CE';
  end;
  end;
  Result := True;
end;

测试

procedure TForm1.Button1Click(Sender: TObject);
var
  a,b,c :String;
begin
  GetVersionInfo(a,b,c);
  ShowMe age(a + #10 + b + #10 + c);
end;

如果你得到的是'Microsoft Windows unknown',请给我来信,写明你用的系统

Email: gpg@mail.csdn.net




 

娱乐图摘

更多 >>

靓丽清纯美女meimei

美女私房全裸照
导演劝女演员脱衣服(视频)

大胆火辣人体艺术写真(图)

黑丝妹妹热辣诱惑-丝袜美女妹妹

PLMM 漂亮妹妹图集-妹妹图库

全球美女图库-美女集中营

52MM 我爱漂亮妹妹-制服妹妹诱惑

图王图库-世界美女明星图片资料库
美女写真集锦

激情两性-解密性生活
浴室MM湿身内衣诱惑
邻家小妹洗澡被偷拍(视频)

热点文章

更多

· 使用MIDAS访问远程Access数据库_Delphi教程_
· Delphi2005学习笔记4——再谈NameSpace和D
· 多层数据库开发十二:使用数据控件_Delphi教程_src1
· 在Delphi中自己建立交叉表_Delphi教程_src11
· 用Delphi设计代理服务器_Delphi教程_src119
· Delphi开发单机瘦数据库程序要点_Delphi教程_sr
· 拖拉打开文件_Delphi教程_src119.com
· 搜索字符串在流中的位置_Delphi教程_src119.co
· 用Delphi编写Win2000服务程序_Delphi教程_
· 創建一個簡單的"專家"_Delphi教程

热点文章

更多