Share via


Icon.ExtractIcon 方法

定义

重载

ExtractIcon(String, Int32, Boolean)

从给定 filePath的 中提取指定的图标。

ExtractIcon(String, Int32, Int32)

从给定 filePath的 中提取指定的图标。

ExtractIcon(String, Int32, Boolean)

Source:
Icon.cs
Source:
Icon.cs

从给定 filePath的 中提取指定的图标。

public static System.Drawing.Icon? ExtractIcon (string filePath, int id, bool smallIcon = false);
static member ExtractIcon : string * int * bool -> System.Drawing.Icon
Public Shared Function ExtractIcon (filePath As String, id As Integer, Optional smallIcon As Boolean = false) As Icon

参数

filePath
String

图标或 PE (.dll 的路径,.exe) 文件。

id
Int32

正数是指给定文件中的图标索引。 负数是指 PE (.dll、.exe) 文件中的特定本机资源标识符。

smallIcon
Boolean

trueIcon获取当前系统小图标大小设置的 。 falseIcon获取当前系统大图标大小设置的 。 默认为 false

返回

Icon如果找不到具有指定 id的图标,则null为 ;如果找不到图标,则为 。

适用于

ExtractIcon(String, Int32, Int32)

Source:
Icon.cs
Source:
Icon.cs

从给定 filePath的 中提取指定的图标。

public:
 static System::Drawing::Icon ^ ExtractIcon(System::String ^ filePath, int id, int size);
public static System.Drawing.Icon? ExtractIcon (string filePath, int id, int size);
static member ExtractIcon : string * int * int -> System.Drawing.Icon
Public Shared Function ExtractIcon (filePath As String, id As Integer, size As Integer) As Icon

参数

filePath
String

图标或 PE (.dll 的路径,.exe) 文件。

id
Int32

正数是指给定文件中的图标索引。 负数是指 PE (.dll、.exe) 文件中的特定本机资源标识符。

size
Int32

所需大小。 如果指定的大小不存在,则会重新采样现有大小,以提供请求的大小。

返回

Icon如果找不到具有指定 id的图标,则null为 ;如果找不到图标,则为 。

例外

size 为负或大于 MaxValue

filePath 无法访问。

filePathnull

注解

与 不同, Icon此方法和 ExtractAssociatedIcon(String) 方法不会保留所有资源数据,也不会根据需要在调整大小) 之外修改原始数据 (。 因此, Icon 仅使用请求大小所需的内存 (大部分本机内存) 。

如果没有原始源数据, Icon 则必须重新采样当前图标的位图以更改大小。 为了获得最佳图像质量,如果需要不同大小的 , Icon 则应使用此方法创建单独的实例,并避免使用复制构造函数。

适用于