vb 获取系统信息

vb 获取系统信息

         象这样的东西还是做成一个类模块吧!

   ' Call   Module   :   CSystem   
   Option     Explicit    
    
  
Private    Type   SYSTEM_INFO   
          wProcessorArchitecture     
As     Integer    
          wReserved   
As     Integer    
          dwPageSize   
As     Long    
          lpMinimumApplicationAddress   
As     Long    
          lpMaximumApplicationAddress   
As     Long    
          dwActiveProcessorMask   
As     Long    
          dwNumberOfProcessors   
As     Long    
          dwProcessorType   
As     Long    
          dwAllocationGranularity   
As     Long    
          wProcessorLevel   
As     Integer    
          wProcessorRevision   
As     Integer    
  
End    Type   
    
  
Private    Declare    Sub    GetSystemInfo   Lib    " KERNEL32 "    (lpSystemInfo    As    SYSTEM_INFO)   
    
  
Private    iWinMajor    As     Integer    
  
Private    iWinMinor    As     Integer    
  
Private    sMode    As     String    
  
Private    sys    As    SYSTEM_INFO   
    
  
Private     Sub    Class_Initialize()   
          
Dim    dw    As     Long ,   c    As     Integer    
          dw   
=    GetVersion()   
          iWinMajor   
=    dw    And     & HFF &    
          iWinMinor   
=    (dw    And     & HFF00 & )    /     & H100 &    
          sMode   
=    IIf(dw    And     & H80000000,    " Windows   95 " ,    " Windows   NT " )   
          GetSystemInfo   sys   
  
End     Sub    
    
  
Property     Get    FreePhysicalMemory()    As     Long    
          
Dim    mem    As    MEMORYSTATUS   
          mem.dwLength   
=     Len (mem)   
          GlobalMemoryStatus   mem   
          FreePhysicalMemory   
=    mem.dwAvailPhys        1024    
  
End     Property    
    
  
Property     Get    TotalPhysicalMemory()    As     Long    
          
Dim    mem    As    MEMORYSTATUS   
          mem.dwLength   
=     Len (mem)   
          GlobalMemoryStatus   mem   
          TotalPhysicalMemory   
=    mem.dwTotalPhys        1024    
  
End     Property    
    
  
Property     Get    FreeVirtualMemory()    As     Long    
          
Dim    mem    As    MEMORYSTATUS   
          mem.dwLength   
=     Len (mem)   
          GlobalMemoryStatus   mem   
          FreeVirtualMemory   
=    mem.dwAvailVirtual        1024    
  
End     Property    
    
  
Property     Get    TotalVirtualMemory()    As     Long    
          
Dim    mem    As    MEMORYSTATUS   
          mem.dwLength   
=     Len (mem)   
          GlobalMemoryStatus   mem   
          TotalVirtualMemory   
=    mem.dwTotalVirtual        1024    
  
End     Property    
    
  
Property     Get    FreePageFile()    As     Long    
          
Dim    mem    As    MEMORYSTATUS   
          mem.dwLength   
=     Len (mem)   
          GlobalMemoryStatus   mem   
          FreePageFile   
=    mem.dwAvailPageFile        1024    
  
End     Property    
    
  
Property     Get    TotalPageFile()    As     Long    
          
Dim    mem    As    MEMORYSTATUS   
          mem.dwLength   
=     Len (mem)   
          GlobalMemoryStatus   mem   
          TotalPageFile   
=    mem.dwTotalPageFile        1024    
  
End     Property    
    
  
Property     Get    MemoryLoad()    As     Long    
          
Dim    mem    As    MEMORYSTATUS   
          mem.dwLength   
=     Len (mem)   
          GlobalMemoryStatus   mem   
          MemoryLoad   
=    mem.dwMemoryLoad   
  
End     Property    
    
  
Property     Get    WinMajor()    As     Integer    
          WinMajor   
=    iWinMajor   
  
End     Property    
    
  
Property     Get    WinMinor()    As     Integer    
          WinMinor   
=    iWinMinor   
  
End     Property    
    
  
Property     Get    WinVersion()    As     Single    
          WinVersion   
=    iWinMajor    +    (iWinMinor    /     100 )   
  
End     Property    
    
  
Property     Get    Processor()    As     String    
          
If    sMode    =     " Windows   95 "     Then    
                  Processor   
=     " Intel    "    
                  
Select     Case    sys.dwProcessorType   
                  
Case     386    
                          Processor   
=    Processor    &     " 386 "    
                  
Case     486    
                          Processor   
=    Processor    &     " 486 "    
                  
Case     586    
                          Processor   
=    Processor    &     " 586 "    
                  
End     Select    
          
Else    
                  
Select     Case    sys.wProcessorArchitecture   
                  
Case    PROCESSOR_ARCHITECTURE_INTEL   
                          Processor   
=     " Intel    "    
                          
Select     Case    sys.wProcessorLevel   
                          
Case     3 ,    4    
                                  Processor   
=    Processor    &    sys.wProcessorLevel    &     " 86 "    
                          
Case     5    
                                  Processor   
=    Processor    &     " Pentium "    
                          
Case     Else    
                                  Processor   
=    Processor    &     " Level    "     &    sys.wProcessorLevel   
                          
End     Select    
                  
Case    PROCESSOR_ARCHITECTURE_MIPS   
                          Processor   
=     " MIPS   R "     &    sys.wProcessorLevel    &     " 000 "    
                  
Case    PROCESSOR_ARCHITECTURE_ALPHA   
                          Processor   
=     " Alpha    "     &    sys.wProcessorLevel   
                  
Case    PROCESSOR_ARCHITECTURE_PPC   
                          Processor   
=     " Power   PC    "     &    IIf(sys.wProcessorLevel    >     9 ,    " 6 " ,    " 60 " )    &    _   
                                                  sys.wProcessorLevel   
                  
Case    PROCESSOR_ARCHITECTURE_UNKNOWN   
                          Processor   
=     " Unknown "    
                  
Case     Else    
                          Processor   
=     " Other    "     &    sys.wProcessorArchitecture    &     "     "     &    sys.wProcessorLevel   
                  
End     Select    
          
End     If    
  
End     Property    
    
  
Property     Get    ProcessorCount()    As     String    
          ProcessorCount   
=    sys.dwNumberOfProcessors   
  
End     Property    
    
  
Property     Get    Mode()    As     String    
          Mode   
=    sMode   
  
End     Property    
    
  
Property     Get    WindowsDir()    As     String    
          
Dim    s    As     String ,   c    As     Long    
          s   
=     String $(cMaxPath,    0 )   
          c   
=    GetWindowsDirectory(s,   cMaxPath)   
          WindowsDir   
=     Left (s,   c)   
  
End     Property    
    
  
Property     Get    SystemDir()    As     String    
          
Dim    s    As     String ,   c    As     Long    
          s   
=     String $(cMaxPath,    0 )   
          c   
=    GetSystemDirectory(s,   cMaxPath)   
          SystemDir   
=     Left (s,   c)   
  
End     Property    
    
  
Property     Get    User()    As     String    
          
Dim    s    As     String ,   c    As     Long    
          c   
=     80 :   s    =     String $(c    +     1 ,    0 )   
          
'    Includes   null   in   returned   length,   unlike   all   other   API   functions   
           If    GetUserName(s,   c)    Then    User    =     Left $(s,   c    -     1 )   
  
End     Property    
    
  
Property     Get    Machine()    As     String    
          
Dim    s    As     String ,   c    As     Long    
          c   
=     16 :   s    =     String $( 16 ,    0 )   
          
If    GetComputerName(s,   c)    Then    Machine    =     Left $(s,   c)   
  
End     Property
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值