• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

VB.Net Problems

Joined
Jan 1, 2001
Messages
581
Howdy,
Currently writing a few apps to try to learn VB.Net a bit better.. Yes i realize that it is a horrendous language, but i figure i should get a headstart on it as im going to have to use it in class next year.

Anyhow, i started writing a pseudo-taskmanager clone, and i've run into a few problems along the way.

First off, i'm looking to show mem-usage in kb just like it does in the task manager window, yet im at a bit of a deadend as to how, im not sure which method would be the correct one, as all seem to return different values then task manager.

And my second and final error occurs when i try to obtain the fullpath of the process, i wrote a function to do this just in case i need to call it for any other purposes. Said function is as follows, assuming that The process is being passed in.

Code:
  Private Function GetFileInfo(ByVal newProcess as Process) As String
      GetFileInfo = newProcess.MainModule.FileName.ToString
  End Function

When i try to get the fileinfo the error is as follows: "Additional Information: Unable to enumerate the process modules."

Any help is appreciated. Thanks.
 
Fixed my second error, i was trying to get the info of System and Idle, hehe, there ar eno locations for those. DOH. :) Anyhow, still having troubles getting the correct memory readings.. Any ideas?
 
kinda hard to figure it out with out the other functions and code. please post.
 
There are hundreds of metrics that can be added... If you want to see how many you can show, simply grab any WinXP or Win2k3 system, open perfmon.exe, and add a counter (look at the available counter list).

But as for the simple ones that don't require performance counters, it's just a matter of knowing what means what, and how to convert.

Here's a simple example that will show the current process list in a listview, along with the memory size as reported by the task manger:
Code:
        Dim Processes As Process() = Process.GetProcesses()
        Dim Proc As Process
        ListView1.Items.Clear()
        For Each Proc In Processes
            ListView1.Items.Add(New ListViewItem(New String() { _
                Proc.ProcessName, _
                [b](Proc.WorkingSet / 1024).ToString("N") & " K"[/b]}))
        Next

You obviously already pretty much had this, except for the last line in the loop.

The amount of physical memory that is mapped to a process is called the "working set", that is the property you were looking for. Since it's reported in bytes, you want to divide by 1024 to convert to KB...
 
Back
Top