Icons and active programs.

NJDubois

Well-known member
Joined
May 15, 2008
Messages
84
Programming Experience
Beginner
I have looked around on the internet and can't seem to find an easy answer to these questions.

How would I make a list similar to the task manager Active Application list? I would like to put a listbox on my form that shows that list and cannot find any resource or tutorial. The keywords active and application give me all sorts of odd google hits and none of them help.

Once I have that list loaded, how do I take the path of the file, say "c:\windows\notepad.exe" And assign the exe's icon to a button in visual basic? I have found these 2 websites but I am still to much of a .net noob to figure it out.

http://www.vbdotnetforums.com/windows-presentation-foundation-wpf/28160-wpf-icon-system-drawing-icon.html

Icons in Win32

There has to be an easy way to read the icon from an exe, but how do you do it?

Thanks in advance for the help!
Nick
 
Follow these instructions and you will get a nice view of active applications:
- Add a ImageList control, set properties ColorDepth to 32 bit and ImageSize to 32x32.
- Add a ListView control, set property LargeImageList to the above list. (leave View as LargeIcon)

Use this code to list processes with icons:
VB.NET:
For Each p As Process In Process.GetProcesses
    If p.MainWindowTitle <> String.Empty Then
        Dim file As String = p.MainModule.FileName
        Me.ImageList1.Images.Add(file, Icon.ExtractAssociatedIcon(file))
        Me.ListView1.Items.Add(p.MainWindowTitle, file)
    End If
Next
You should be getting a view like this:
listviewprocesses.png
 
Thank you!

I knew that there had to be an easy way to do this! Much much thanks!

Next, how do I click on one of those icons and bring that window up? Also, open folders did not appear in the list?

Thanks again.
Nick
 
Back
Top