How to get the user processes with the icon's of the processes in RRS feed

  • Question

  • Like in the taskmanager: 

    Hi! I'am currently making my DLL injector, I'am done, but I want a little bit better design, and I think its a good idea, but I don't know how to do it. Any help?
    Wednesday, July 4, 2018 9:26 AM

All replies

  • With SHGetFileInfo (Taskmgr uses PrivateExtractIcons)

    A test with Explorer :

    Dim sfi As New SHFILEINFO
    Dim hImageList As IntPtr = SHGetFileInfo("C:\windows\explorer.exe", 0, sfi, Marshal.SizeOf(sfi), SHGFI_ICON)
    Dim ico As Icon = Icon.FromHandle(sfi.hIcon)
    Dim gr As Graphics = Graphics.FromHwnd(IntPtr.Zero)
    gr.DrawIcon(ico, 50, 50)

    with :

    Public Const SHGFI_ICON = &H100
    Public Structure SHFILEINFO
        Public hIcon As IntPtr
        Public iIcon As Integer
        Public dwAttributes As Integer
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public szDisplayName As String
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> Public szTypeName As String
    End Structure
    <DllImport("Shell32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
    Public Shared Function SHGetFileInfo(pszPath As String, dwFileAttributes As UInteger, ByRef psfi As SHFILEINFO, cbFileInfo As UInteger, uFlags As UInteger) As IntPtr
    End Function

    • Edited by Castorix31 Wednesday, July 4, 2018 10:33 AM
    • Proposed as answer by tommytwotrain Wednesday, July 4, 2018 12:09 PM
    Wednesday, July 4, 2018 10:16 AM
  •  Below is a link to a small "tutorial" I made of using the same SHGetFileInfo api function as Castorix31 has shown.  Don't confuse the IconHelper class in the link below with the IconHelper class that I posted in the link that TommyTwoTrains gave you a link for,  they are different.  The class in the link below only gets 32x32 or 16x16 sized icons and the one Tom posted a link for will get 16x16,  32x32, 48x48, or 256x256 sized icons.  However,  you probably only need the 16x16 or 32x32 sized icons for your case.

     Get Icon Images Of Files, Folders, Drives, or Registered Files

    If you say it can`t be done then i`ll try it

    Wednesday, July 4, 2018 4:32 PM
  • Hi 

    Maybe you can get the file icon like this,I hope I can help you

     Dim icon1 As Icon = System.Drawing.Icon.ExtractAssociatedIcon("C:\Users\alexl2\Desktop\Capture.exe")
            PictureBox1.Image = icon1.ToBitmap()
            Dim icon2 As Icon = System.Drawing.Icon.ExtractAssociatedIcon("C:\Program Files (x86)\360\360zip\360zip.exe")
            PictureBox2.Image = icon2.ToBitmap()

    Best Regards,


    MSDN Community Support Please remember to click &amp;amp;amp;quot;Mark as Answer&amp;amp;amp;quot; the responses that resolved your issue, and to click &amp;amp;amp;quot;Unmark as Answer&amp;amp;amp;quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Proposed as answer by tommytwotrain Thursday, July 5, 2018 11:20 AM
    Thursday, July 5, 2018 6:20 AM