none
Windows 10 Taskbar Thumbnails RRS feed

  • Question

  • Hi,

    I'm trying to find out how to get a copy of the thumbnail that shows on the Windows 10 taskbar when you hover over a running process. I have the process ids for those that I want and I need to get the thumbnails for them and store them as an image (bitmap, jpeg or whatever).

    Any ideas?

    Rob

    Tuesday, January 14, 2020 10:48 AM

All replies

  • It is done with DwmRegisterThumbnail
    Tuesday, January 14, 2020 11:05 AM
  • Hi Rob,

    Thank you for posting here.

    If you already know the process ID, you can use the following code to get its taskbar icon.

    private void button1_Click_1(object sender, EventArgs e) { ManagementClass MgmtClass = new ManagementClass("Win32_Process"); Icon TheIcon; foreach (ManagementObject mo in MgmtClass.GetInstances()) {

    // 22504 is Chrome's processid. if (mo["ProcessId"].ToString() == "22504") { TheIcon = IconFromFilePath(mo["ExecutablePath"].ToString()); pictureBox1.Image = TheIcon.ToBitmap(); } } } public static Icon IconFromFilePath(string filePath) { Icon result = null/* TODO Change to default(_) if this is not a reference type */; try { result = Icon.ExtractAssociatedIcon(filePath); } catch { } return result; }


    Result:

    Hope this could be helpful.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" 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 MSDNFSF@microsoft.com.

    Wednesday, January 15, 2020 6:34 AM
  • Hi Timon,

    Thanks for the suggestion. I'm actually after the thumbnail image that popsup when you hover over the icon. I've managed to do this using the rather longwinded way of registering the thumbnail and then associating it with a window (DwmRegisterThumbnail & DwmUpdateThumbnailProperties).

    The problem I am having now is trying to render the image into a bitmap or similar. If I try to render the window I just get whitespace.

    So I'm still open to suggestions!

    Rob

    Wednesday, January 15, 2020 9:54 AM
  • The problem I am having now is trying to render the image into a bitmap or similar. If I try to render the window I just get whitespace.

    So I'm still open to suggestions!

    I had tested with D3DXSaveSurfaceToFileInMemory

    and it worked on Windows 10.


    • Edited by Castorix31 Wednesday, January 15, 2020 10:17 AM
    • Proposed as answer by simonb549 Tuesday, February 18, 2020 8:31 AM
    Wednesday, January 15, 2020 10:14 AM
  • Hi Rob,

    Take a look at this link, although it is a long ago blog, it still works on windows 10.

    PROGRAMMING THE WINDOWS VISTA DWM IN C#

    This link does not exactly meet your requirements, but may give you some ideas.

    This is the author's code, you can download it if needed:

    dwmtest.zip

    You can also try Castorix31's suggestion, which may be a better way.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" 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 MSDNFSF@microsoft.com.


    Thursday, January 16, 2020 3:16 AM
  • Hi Rob,

    Has your problem been solved?

    If so, please click "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Timon

     

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" 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 MSDNFSF@microsoft.com.

    Tuesday, February 18, 2020 8:22 AM