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. getting memory info from wmi

getting memory info from wmi

Scheduled Pinned Locked Moved Visual Basic
performancehelplounge
5 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.
  • D Offline
    D Offline
    dduffy
    wrote on last edited by
    #1

    Hi there, this might be quite simple to do but i'm new to this, so what i would like to do is display the computers RAM as showing on the computer properties general tab, just under the processor info. i want to show as 512MB, rather than in bytes. please help. thanks:-D

    L 1 Reply Last reply
    0
    • D dduffy

      Hi there, this might be quite simple to do but i'm new to this, so what i would like to do is display the computers RAM as showing on the computer properties general tab, just under the processor info. i want to show as 512MB, rather than in bytes. please help. thanks:-D

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, these are the steps: - get the size (you seem to do this with WMI), it will be a long 32-bit integer BTW: I am C# programmer who prefers to use P/Invoke to call GlobalMemoryStatus() in kernel32.dll, since I don't like WMI that much, it is slow for starters - optionally: round it to a multiple of whatever seems appropriate - divide by 1024*1024 - show it somehow (maybe as Label.Text) You should get most of this working, then ask a detailed question if and when you're stuck. :) -- modified at 17:47 Monday 6th August, 2007

      Luc Pattyn [Forum Guidelines] [My Articles]


      this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


      D 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, these are the steps: - get the size (you seem to do this with WMI), it will be a long 32-bit integer BTW: I am C# programmer who prefers to use P/Invoke to call GlobalMemoryStatus() in kernel32.dll, since I don't like WMI that much, it is slow for starters - optionally: round it to a multiple of whatever seems appropriate - divide by 1024*1024 - show it somehow (maybe as Label.Text) You should get most of this working, then ask a detailed question if and when you're stuck. :) -- modified at 17:47 Monday 6th August, 2007

        Luc Pattyn [Forum Guidelines] [My Articles]


        this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


        D Offline
        D Offline
        Drew
        wrote on last edited by
        #3

        What he said. (or she, just to be fair :)) 1024^2 turns out to be 1048576. What I did was take the straight value from My.Computer.Info.TotalPhysicalMemory and divide it by 1048576 and added Mb to the end. And there you have it.

        L 1 Reply Last reply
        0
        • D Drew

          What he said. (or she, just to be fair :)) 1024^2 turns out to be 1048576. What I did was take the straight value from My.Computer.Info.TotalPhysicalMemory and divide it by 1048576 and added Mb to the end. And there you have it.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Looks good, I forgot VB offers more info through My.Computer than the other CLR languages do. BTW: I would not write 1048576 since that looks like a magic number, I really write 1024*1024 which meaning I trust is obvious for everyone, and is less error prone. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


          D 1 Reply Last reply
          0
          • L Luc Pattyn

            Looks good, I forgot VB offers more info through My.Computer than the other CLR languages do. BTW: I would not write 1048576 since that looks like a magic number, I really write 1024*1024 which meaning I trust is obvious for everyone, and is less error prone. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


            D Offline
            D Offline
            Drew
            wrote on last edited by
            #5

            I usually assign a global variable to 1024^2, but I wrote this app before I started doing that (shortly after you posted your previous post ;))

            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