Results 1 to 3 of 3

Thread: Getting System Info with VB ... ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    84
    Are there any VB commands to get System Info?

    I mean - simple commands to use instead of searching through a registry? I thought I had read something about this once, but I'm having trouble finding anything.

    I'm looking for:
    Operating System
    Processor Make (name),
    Processor Speed,
    Amount of Physical RAM

    And Possibly:
    FSB Speed
    AGP Rate
    Name of Videocard
    Name (description) of Videocard drivers being used

    Thanks.




  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151

    From MSDN

    I copied the following from MSDN. It references VB 5.0, but is probably applicable to 6.0 also. I have 6.0, and this is the latest version of MSDN. This stuff probably has not changed since 5.0. I doubt that it would work with earlier versions.

    I hope it helps. Note: The following might not be everything possible from the Sysinfo control. If you do not know how to obtain Sysinfo control, I might be able to help. I put one on my toolbar a while ago, and might be able to figure it out again.

    Steps to Create Example Program
    Start Visual Basic 5.0 and select Standard EXE. If Visual Basic 5.0 is already running, click New Project on the File menu, and select Standard EXE. Form1 is created by default.


    On the Project menu, click Add Module (press ALT,P,M). Module1 is created by default.


    Enter the following code into the General Declarations section of a code module:
    Code:
    
    
          Type SYSTEM_INFO
                dwOemID As Long
                dwPageSize As Long
                lpMinimumApplicationAddress As Long
                lpMaximumApplicationAddress As Long
                dwActiveProcessorMask As Long
                dwNumberOrfProcessors As Long
                dwProcessorType As Long
                dwAllocationGranularity As Long
                dwReserved As Long
          End Type
          Type OSVERSIONINFO
                dwOSVersionInfoSize As Long
                dwMajorVersion As Long
                dwMinorVersion As Long
                dwBuildNumber As Long
                dwPlatformId As Long
                szCSDVersion As String * 128
          End Type
          Type MEMORYSTATUS
                dwLength As Long
                dwMemoryLoad As Long
                dwTotalPhys As Long
                dwAvailPhys As Long
                dwTotalPageFile As Long
                dwAvailPageFile As Long
                dwTotalVirtual As Long
                dwAvailVirtual As Long
          End Type
    
          Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
             (LpVersionInformation As OSVERSIONINFO) As Long
          Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As _
             MEMORYSTATUS)
          Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As _
             SYSTEM_INFO)
    
          Public Const PROCESSOR_INTEL_386 = 386
          Public Const PROCESSOR_INTEL_486 = 486
          Public Const PROCESSOR_INTEL_PENTIUM = 586
          Public Const PROCESSOR_MIPS_R4000 = 4000
          Public Const PROCESSOR_ALPHA_21064 = 21064
    Enter the following code into the Form_Load procedure of Form1:
    Code:
    
    
          Private Sub Form_Load()
             Dim msg As String         ' Status information.
    
             Show
             MousePointer = 11   ' Hourglass.
    
                 ' Get operating system and version.
                 Dim verinfo As OSVERSIONINFO
                 Dim build As String, ver_major As String, ver_minor As String
                 Dim ret As Long
                 verinfo.dwOSVersionInfoSize = Len(verinfo)
                 ret = GetVersionEx(verinfo)
                 If ret = 0 Then
                     MsgBox "Error Getting Version Information"
                     End
                 End If
                 Select Case verinfo.dwPlatformId
                     Case 0
                         msg = msg & "Windows 32s "
                     Case 1
                         msg = msg & "Windows 95/98 "
                     Case 2
                         msg = msg & "Windows NT "
                 End Select
    
                 ver_major = verinfo.dwMajorVersion
                 ver_minor = verinfo.dwMinorVersion
                 build = verinfo.dwBuildNumber
                 msg = msg & ver_major & "." & ver_minor
                 msg = msg & " (Build " & build & ")" & vbCrLf & vbCrLf
    
                 ' Get CPU type and operating mode.
                 Dim sysinfo As SYSTEM_INFO
                 GetSystemInfo sysinfo
                 msg = msg & "CPU: "
                 Select Case sysinfo.dwProcessorType
                     Case PROCESSOR_INTEL_386
                         msg = msg & "Intel 386" & vbCrLf
                     Case PROCESSOR_INTEL_486
                         msg = msg & "Intel 486" & vbCrLf
                     Case PROCESSOR_INTEL_PENTIUM
                         msg = msg & "Intel Pentium" & vbCrLf
                     Case PROCESSOR_MIPS_R4000
                         msg = msg & "MIPS R4000" & vbCrLf
                     Case PROCESSOR_ALPHA_21064
                         msg = msg & "DEC Alpha 21064" & vbCrLf
                     Case Else
                         msg = msg & "(unknown)" & vbCrLf
    
                 End Select
                 msg = msg & vbCrLf
                 ' Get free memory.
                 Dim memsts As MEMORYSTATUS
                 Dim memory As Long
                 GlobalMemoryStatus memsts
                 memory = memsts.dwTotalPhys
                 msg = msg & "Total Physical Memory: "
                 msg = msg & Format$(memory \ 1024, "###,###,###") & "K" _
                           & vbCrLf
                 memory& = memsts.dwAvailPhys
                 msg = msg & "Available Physical Memory: "
                 msg = msg & Format$(memory \ 1024, "###,###,###") & "K" _
                           & vbCrLf
                 memory& = memsts.dwTotalVirtual
                 msg = msg & "Total Virtual Memory: "
                 msg = msg & Format$(memory \ 1024, "###,###,###") & "K" _
                           & vbCrLf
                 memory& = memsts.dwAvailVirtual
                 msg = msg & "Available Virtual Memory: "
                 msg = msg & Format$(memory \ 1024, "###,###,###") & "K" _
                           & vbCrLf & vbCrLf
    
             Print msg
             MousePointer = 0
          End Sub
    On the Run menu, click Start, or press the F5 key to start the program.



    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151

    Try API Forum.

    If my previous Post did not help, try Posting in the API Forum. The people who work with that Forum are likely to have lots of advice on your question.
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width