gpt4 book ai didi

c# - 如何在 C# 中获取窗口的图标

转载 作者:行者123 更新时间:2023-11-30 22:29:52 26 4
gpt4 key购买 nike

如何从窗口的指针或进程/进程名称中获取窗口的图标?显示在窗口一角、任务栏或 ALT-Tab 菜单中的图标。

最佳答案

了解Icon.ExtractAssociatedIcon:

Returns an icon representation of an image that is contained in the specified file.

private void ExtractAssociatedIconEx()
{
Icon ico =
Icon.ExtractAssociatedIcon(@"C:\WINDOWS\system32\notepad.exe");
this.Icon = ico;

}

http://msdn.microsoft.com/en-us/library/system.drawing.icon.extractassociatedicon.aspx

这不会对每个过程都有效,但这是一个好的开始..

也看看那些答案 - How can I get the icon from the executable file only having an instance of it's Process in C#

关于c# - 如何在 C# 中获取窗口的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9968648/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com