how to get cpu info, mem, etc
-
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
-
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
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
-
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
thx... lets see if this works...
-
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
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