Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to get cpu info, mem, etc

how to get cpu info, mem, etc

Scheduled Pinned Locked Moved Visual Basic
csharpperformancetutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brokenshard
    wrote on last edited by
    #1

    I have just started with VB.NET and was wondering how do i get things like windows version, ip of my machine, cpu and memory information. I want to get them and display it in a label/textbox. thx

    V D 2 Replies Last reply
    0
    • B brokenshard

      I have just started with VB.NET and was wondering how do i get things like windows version, ip of my machine, cpu and memory information. I want to get them and display it in a label/textbox. thx

      V Offline
      V Offline
      vancouver777
      wrote on last edited by
      #2

      I am not sure it works in .Net but here is how to do it in vb. I just found this, so you have to find a way to be compilable. Thanks, Shin Option Explicit Private 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 Private 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 Private Declare Sub GetSystemInfo Lib "kernel32" ( _ lpSystemInfo As SYSTEM_INFO) Private Declare Sub GlobalMemoryStatus Lib "kernel32" ( _ lpBuffer As MEMORYSTATUS) Private Sub Form_Load() Dim Sys As SYSTEM_INFO Dim tMem As MEMORYSTATUS GetSystemInfo Sys GlobalMemoryStatus tMem Debug.Print "Percentage of memory currently in use : " & Format(1 - (tMem.dwAvailPhys / tMem.dwTotalPhys), "00.00 %") Debug.Print "Total Available : " & Format(tMem.dwAvailPhys, "### ### ###") Debug.Print "Total Physical : " & Format(tMem.dwTotalPhys, "### ### ###") Debug.Print "Total Virtual : " & Format(tMem.dwTotalVirtual, "### ### ### ###") Debug.Print "Processor Type : " & Sys.dwProcessorType Debug.Print "Number of Processor(s) : " & Sys.dwNumberOrfProcessors End Sub

      B 1 Reply Last reply
      0
      • V vancouver777

        I am not sure it works in .Net but here is how to do it in vb. I just found this, so you have to find a way to be compilable. Thanks, Shin Option Explicit Private 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 Private 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 Private Declare Sub GetSystemInfo Lib "kernel32" ( _ lpSystemInfo As SYSTEM_INFO) Private Declare Sub GlobalMemoryStatus Lib "kernel32" ( _ lpBuffer As MEMORYSTATUS) Private Sub Form_Load() Dim Sys As SYSTEM_INFO Dim tMem As MEMORYSTATUS GetSystemInfo Sys GlobalMemoryStatus tMem Debug.Print "Percentage of memory currently in use : " & Format(1 - (tMem.dwAvailPhys / tMem.dwTotalPhys), "00.00 %") Debug.Print "Total Available : " & Format(tMem.dwAvailPhys, "### ### ###") Debug.Print "Total Physical : " & Format(tMem.dwTotalPhys, "### ### ###") Debug.Print "Total Virtual : " & Format(tMem.dwTotalVirtual, "### ### ### ###") Debug.Print "Processor Type : " & Sys.dwProcessorType Debug.Print "Number of Processor(s) : " & Sys.dwNumberOrfProcessors End Sub

        B Offline
        B Offline
        brokenshard
        wrote on last edited by
        #3

        thx... lets see if this works...

        1 Reply Last reply
        0
        • B brokenshard

          I have just started with VB.NET and was wondering how do i get things like windows version, ip of my machine, cpu and memory information. I want to get them and display it in a label/textbox. thx

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          The other example code that was posted should work, but it's easier to do with the System.Management namespace. If your just learning VB.NET, and have no other programming experience, it can be very confusing to use though. There are no articles on CodePorject in VB.NET, but there are in C#. Try this[^] for a list of articles. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups