CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  基础类

如何获取操作系统信息?

楼主Tenner(BE.Tenner)2002-02-02 14:34:10 在 VB / 基础类 提问

如何获取操作系统信息?即如何知道当前的操作系统是   Win95   还是   WinXP   等?  
  是通过版本吗?那Win95   --   WinXP   的版本各是多少呢?  
  我要知道   Win95/97/98/ME/NT/2000/XP 问题点数:50、回复次数:5Top

1 楼visualbaby(好好学习天天向上)回复于 2002-02-02 14:40:06 得分 15

 
  下面这段代码可以判断win95/98和nt,但是xp我不知道行不行  
  Private   Type   OSVERSIONINFO  
          dwOSVersionInfoSize   As   Long  
          dwMajorVersion   As   Long  
          dwMinorVersion   As   Long  
          dwBuildNumber   As   Long  
          dwPlatformId   As   Long  
          szCSDVersion   As   String   *   128  
  End   Type  
   
  Private   Declare   Function   GetVersionEx   Lib   "kernel32"   Alias   _  
          "GetVersionExA"   (lpVersionInformation   As   _  
          OSVERSIONINFO)   As   Boolean  
   
  Private   Const   VER_PLATFORM_WIN32s   =   0  
  Private   Const   VER_PLATFORM_WIN32_WINDOWS   =   1  
  Private   Const   VER_PLATFORM_WIN32_NT   =   2  
   
  Private   Sub   Command1_Click()  
          Dim   Ver   As   OSVERSIONINFO  
          Ver.dwOSVersionInfoSize   =   Len(Ver)  
          Call   GetVersionEx(Ver)  
          If   Ver.dwPlatformId   =   0   Then  
                  MsgBox   "Win32"  
          ElseIf   Ver.dwPlatformId   =   1   Then  
                  MsgBox   "Win95,Win98"  
          ElseIf   Ver.dwPlatformId   =   2   Then  
                  MsgBox   "Winnt"  
          Else  
                  MsgBox   "Error"  
          End   If  
  End   Sub  
  Top

2 楼ferrytang(欢迎你)回复于 2002-02-02 14:40:15 得分 15

GetSystemInfo    
   
  VB声明    
  Declare   Sub   GetSystemInfo   Lib   "kernel32"   Alias   "GetSystemInfo"   (lpSystemInfo   As   SYSTEM_INFO)    
  说明    
  在一个SYSTEM_INFO结构中载入与底层硬件平台有关的信息    
  参数表    
  参数   类型及说明    
  lpSystemInfo   SYSTEM_INFO,指定一个结构,用于装载适当的系统信息    
   
   
  SYSTEM_INFO    
   
  类型定义    
  Type   SYSTEM_INFO   '   36   Bytes    
  dwOemID   As   Long  
  dwPageSize   As   Long  
  lpMinimumApplicationAddress   As   Long  
  lpMaximumApplicationAddress   As   Long  
  dwActiveProcessorMask   As   Long  
  dwNumberOrfProcessors   As   Long  
  dwProcessorType   As   Long  
  dwAllocationGranularity   As   Long  
  wProcessorLevel   As   Integer  
  wProcessorRevision   As   Integer  
  End   Type    
  说明    
  This   structure   contains   information   regarding   the   current   computer   system.  
     
  字段表    
  字段   类型与说明    
  dwOemID   Long,System   processor   used.   In   Windows   95,   this   value   is   always   set   to   zero   (PROCESSOR_ARCHITECTURE_INTEL).   In   Windows   NT,   this   value   may   be   one   of   the   following   :   PROCESSOR_ARCHITECTURE_INTEL,   PROCESSOR_ARCHITECTURE_MIPS,   PROCESSOR_ARCHITECTURE_ALPHA,   PROCESSOR_ARCHITECTURE_PPC    
  dwPageSize   Long,Page   size   used.   Also   specifies   the   granularity   of   page   protection   and   commitment.    
  lpMinimumApplicationAddress   Long,Contains   the   lowest   memory   address   that   applications   and   dynamic   link   libraries   (DLLs)   can   access.    
  lpMaximumApplicationAddress   Long,Contains   the   highest   memory   address   that   applications   and   DLLs   can   access.    
  dwActiveProcessorMask   Long,Contains   a   mask   representing   the   set   of   processors   available   on   the   system.   Processor   zero   is   indicated   by   bit   zero   being   set.    
  dwNumberOrfProcessors   Long,The   number   of   processors   in   this   system.    
  dwProcessorType   Long,Obsolete,   but   maintained   for   backward   compatibility.   Can   be   one   of   the   following   values:   PROCESSOR_INTEL_386,   PROCESSOR_INTEL_486,   PROCESSOR_INTEL_PENTIUM.   The   following   are   valid   on   Windows   NT   systems   only:   PROCESSOR_MIPS_R4000,   PROCESSOR_ALPHA_21046    
  dwAllocationGranularity   Long,Contains   the   allocation   granularity   used   to   allocate   memory.   This   value   is   usually   set   to   64K.    
  wProcessorLevel   Integer,Specifies   the   processor   level.   This   value   depends   on   the   PROCESSOR_ARCHITECTURE_*   value   in   the   dwOemID   field.   For   PROCESSOR_ARCHITECTURE_INTEL,   the   valid   values   are   currently:   3   for   a   386   CPU,   4   for   a   486   CPU,   and   5   for   a   Pentium.    
  wProcessorRevision   Integer,Specifies   the   processor   revision.   This   value   depends   on   the   PROCESSOR_ARCHITECTURE_*   value   in   the   dwOemID   field.    
  Top

3 楼pctommy(pctommy)回复于 2002-02-02 14:41:13 得分 0

right,  
  不过,XP我也没试过Top

4 楼tg123(T.G.)回复于 2002-02-02 14:43:57 得分 20

Private   Declare   Function   GetVersionEx   Lib   "kernel32"   Alias   "GetVersionExA"   (lpVersionInformation   As   OSVERSIONINFO)   As   Long  
  Private   Type   OSVERSIONINFO  
          dwOSVersionInfoSize   As   Long  
          dwMajorVersion   As   Long  
          dwMinorVersion   As   Long  
          dwBuildNumber   As   Long  
          dwPlatformId   As   Long  
          szCSDVersion   As   String   *   128  
  End   Type  
  Private   Sub   Form_Load()  
          Dim   OSInfo   As   OSVERSIONINFO,   PId   As   String  
          'KPD-Team   1998  
          'URL:   http://www.allapi.net/  
          'KPDTeam@Allapi.net  
          'Set   the   graphical   mode   to   persistent  
          Me.AutoRedraw   =   True  
          'Set   the   structure   size  
          OSInfo.dwOSVersionInfoSize   =   Len(OSInfo)  
          'Get   the   Windows   version  
          Ret&   =   GetVersionEx(OSInfo)  
          'Chack   for   errors  
          If   Ret&   =   0   Then   MsgBox   "Error   Getting   Version   Information":   Exit   Sub  
          'Print   the   information   to   the   form  
          Select   Case   OSInfo.dwPlatformId  
                  Case   0  
                          PId   =   "Windows   32s   "  
                  Case   1  
                          PId   =   "Windows   95/98"  
                  Case   2  
                          PId   =   "Windows   NT   "  
          End   Select  
          Print   "OS:   "   +   PId  
          Print   "Win   version:"   +   str$(OSInfo.dwMajorVersion)   +   "."   +   LTrim(str(OSInfo.dwMinorVersion))  
          Print   "Build:   "   +   str(OSInfo.dwBuildNumber)  
  End   Sub  
   
  是什么可以看  
        Print   "Win   version:"   +   str$(OSInfo.dwMajorVersion)   +   "."   +   LTrim(str(OSInfo.dwMinorVersion))  
   
  4.9   &   win05/98就是me  
  5.1   &   winnt   就是xp  
  Top

5 楼visualbaby(好好学习天天向上)回复于 2002-02-02 15:44:26 得分 0

谢谢楼上的补充!!!Top

相关问题

  • 请问如何获取操作系统的版本信息?
  • 如何用javascript获取操作系统的信息?(急)
  • jsp如何获取客户端的操作系统和ie的版本等信息!?
  • [请教]ASP页面如何获取客户端操作系统等的详细信息?
  • VB6中获取当前操作系统信息
  • 获取操作系统信息的问题
  • 30分:获取登陆IP,操作系统信息怎么搞
  • 如何获取操作系统的版本和系统目录?
  • 如何获取lan中其他机器的操作系统
  • 如何获取操作系统设置的Temp目录?

关键词

  • .net
  • win32
  • win95
  • 操作系统
  • nt
  • ver
  • dwplatformid
  • osversioninfo
  • win
  • platform

得分解答快速导航

  • 帖主:Tenner
  • visualbaby
  • ferrytang
  • tg123

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo