Click here to Skip to main content
15,915,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sorry if the question is not good, couldn't figure out any way to make it better. I'm looping through processes and trying to get the associated icon for each process. However, I'm only getting the icon for the first file??? I think I just need some fresh eyes.

VB
For Each OneProcess As Process In Process.GetProcesses
    strName = Process.GetProcessesByName(OneProcess.ProcessName)(0).MainModule.FileName.ToString()

    exeIcon = Icon.ExtractAssociatedIcon(strName)
    imgList.Images.Add(exeIcon)

    blist.Items.Add(imgList.Images(0))
    blist.Items.Add(strName)
    blist.Items.Add(OneProcess.Id)
Next


I left some error checking out so the code would be small, but you should be able to see why I'm only getting the first icon. (blist is for a custom listview). Any help appreciated...
Posted
Updated 26-Sep-15 16:14pm
v4
Comments
jumper77 27-Sep-15 7:32am    
@Abdul Thank you. I will look into that. Really appreciate your help.

1 solution

I don't know why you deleted your comment, but you were right. Here's all I had to do...
imgList.Images.Add(exeIcon)
blist.Items.Add(imgList.Images(i))
blist.Items.Add(strName)
blist.Items.Add(p.Id)
i += 1


instead of referencing imglist.Images(0) all the time, incriminating "i" did the trick. Thanks a bunch. I feel like a dummy about this, but I'm just happy it's working now.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900