|
-
Dec 25th, 2009, 10:33 PM
#1
Thread Starter
Junior Member
[RESOLVED]proc.MainModule.FileName has repeated file path.
As in the title, in my program, i use that code for getting the file path of a process, once it gets the path, it is put into a list view which has details like the task manager. the code works fine the first time, but with a little bug that is, when it reaches the vhost of my program. For some reason, it just copies the file path of my program even though the process has changed. After the code has gone through, i want it to refresh the list so as doing the same as when loaded...so I let it refresh and once again it copies the path of the vhost, but this time it has basically taken over every process' location. So in turn, I only get returned my programs location, for something like the task managers location, where it would be like "C:\Windows\system32\tskmgr.exe"
Here's the code:
VB Code:
Private Sub frmmain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Process As New Process()
Dim Count As Integer = 0
lstvproc.Items.Clear()
For Each Process In Process.GetProcesses(My.Computer.Name)
On Error Resume Next
lstvproc.Items.Add(Process.ProcessName() + ".exe")
lstvproc.Items(Count).SubItems.Add(FormatNumber(Process.WorkingSet64 / 1024, NumDigitsAfterDecimal:=0) & " K")
If Process.MainModule.FileName = "" Then <<< starts here.
lstvproc.Items(Count).SubItems.Add("")
Else
lstvproc.Items(Count).SubItems.Add(Process.MainModule.FileName)
End If
lstvproc.Items(Count).SubItems.Add(Process.Id)
Count += 1
Next
tmrcpu.Start()
tlblproc.Text = "Processes: " & lstvproc.Items.Count
End Sub
The refresh code is frmmain_Load(Nothing, Nothing) just to make things easy for me right now, while i get that part of the program going.
To me it seems to be working fine, but why it does that what it does, im not sure. as you can see, the process changes. and Ive even checked it through run time, and each and every time, the process.processname changes. Any help will be greatly appreciated, thanks in advance.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|