try running the program as admin? And/or running the IDE as administrator.
Running Visual Studio as normal user (notice error list)
code from image
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim _allProcs() As Process = Process.GetProcesses() '' a list of ALL running processes
Dim _outString As New System.Text.StringBuilder
Dim _outError As New System.Text.StringBuilder
_outError.AppendLine("ERROR: ")
For Each _proc As Process In _allProcs
Try
_outString.AppendLine(_proc.ProcessName & " id: " & _proc.Id.ToString() & " file: " & _proc.MainModule.FileName)
Catch ex As Exception
_outError.AppendLine(_proc.ProcessName & "->id: " & _proc.Id())
End Try
Next
MessageBox.Show(_outString.ToString() & Environment.NewLine & _outError.ToString())
End Sub
Running the IDE as Admin (you are able to access more of the programs).
Let me know if that helps. Use a Try/Catch block --> If an exception is thrown, it's probably because "Access is denied". If it's a system process, simply ignore it. Use code similar to mine and first see which processes you can't access, and if you can access your game. If you absolutely must get access to the process, try manually calling OpenProcess() and see if you can get a valid handle / with what access rights. When I ran the above code there were only 3 processes which I couldn't access as Admin: "System", "Idle" and some third one.
edited: I've never used a listview. Good Luck. --you were shown above how to use process.mainmodule.filename to get the icon, and the icon class has a convenient ToBitmap() function. I'm not sure what format/class the listview expects, but I think you have what you need.
As far as duplicates..create a new List(Of String) (or another 'collection' type that grows automatically), and each time you add a process to the list, also record its .ProcessName and .Id. Then, only add a process to the listView if that name/id haven't already been added to the list. Careful as some programs can/will have several copies running (think multiboxing). Have you every worked with arrays or other containers?
edit2:
Dim imageListSmall As New ImageList()
Dim imageListLarge As New ImageList()
' Initialize the ImageList objects with bitmaps.
imageListSmall.Images.Add(Bitmap.FromFile("C:\1.pn g"))
imageListLarge.Images.Add(Bitmap.FromFile("C:\3.pn g"))
'Assign the ImageList objects to the ListView.
ProcessList.LargeImageList = imageListLarge
ProcessList.SmallImageList = imageListSmall
So you're 1) Createing a NEW ImageList, then 2) Adding a BITMAP to it and 3) Assigning the ImageList to the listview. We showed you how to get an ICON object from the filepath, and then you can convert that to a bitmap by calling .ToBitmap() on it. Basically the same as you're already doing (adding a bitmap to the imagelist). That should work the same?
But there is a problem with your logic...it will erase any icons that are already in the list. ? You create a NEW ImageList and then add 2 images to it. Any images that were in the old list don't get saved. I'm sure you could set your imageList == ListView.Images to get a reference to that list, and just add to it (?) I'm not sure, haven't worked with listviews, sorry. Or use a For loop and add all the process icons to the imagelist in one go.