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

标签 c# .net pointers window icons

如何从窗口的指针或进程/进程名称获取窗口的图标?显示在窗口一角、任务栏或 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/

相关文章:

c# - 如何使用 CSS 在同一行上对齐两个文本框

c# - 当你有句柄时是 int 还是 IntPtr?

c++ - 为什么我得到一个无效指针?

c - 指针解引用数组

c# - 在不重新编译整个应用程序的情况下升级依赖的 DLL

c - 通过引用修改结构与其他指针之间的区别

C# - 从 TreeView 节点获取文件/文件夹路径

C# 属性强制属性

.net - 为什么我的 Direct2D 绘图性能如此糟糕?

.net - CLR 错误 :8007000b