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