你如何从shell32.dll中获取图标?

Jay*_*ney 46 windows icons

我想将Tree图标用于本土应用程序.有谁知道如何以.icon文件的形式提取图像?我想要16x16和32x32,或者我只是做一个屏幕截图.

小智 48

如果有人想要一个简单的方法,只需使用7zip解压缩shell32.dll并查找文件夹.src/ICON /


jm.*_*jm. 45

在Visual Studio中,选择"文件打开...",然后选择"文件...".然后选择Shell32.dll.应打开文件夹树,您将在"Icon"文件夹中找到图标.

要保存图标,可以右键单击文件夹树中的图标,然后选择"导出".

  • @Bagorolin这是一个方便的关键http://www.glennslayden.com/code/shell32_icons.jpg (5认同)
  • 当我使用这个我只有这个文件夹树和列出的所有图标,但没有预览,标题不是有用的(1,10,1001,..)有没有办法获得预览或我真的有打开所有图标? (2认同)
  • @MickyD无法确认-在VS Community 2017(15.8.3)中,导出图标对我而言就像是一种魅力-就像此答案中所写的一样。菜单可能有所更改-现在是“文件”->“打开”->“文件...”。(我将shell32.dll复制到我的桌面上对此进行了测试) (2认同)
  • 截至 2023 年,此解决方案不再适用于 Windows 10 或 11。 [TheManInOz 的答案](/sf/answers/4984061351/) 是目前唯一正确的答案。 (2认同)

The*_*nOz 28

不确定我是否 100% 正确,但根据我的测试,上述使用 7Zip 或 VS 的选项不适用于 Windows 10 / 11 版本的 imageres.dll 或 shell32.dll。这是我看到的内容:

[shell32.dll]
.rsrc\MANIFEST\124
.rsrc\MUI\1
.rsrc\TYPELIB\1
.rsrc\version.txt
.data
.didat
.pdata
.rdata
.reloc
.text
CERTIFICATE
Run Code Online (Sandbox Code Playgroud)

更新:我想我找到了原因。链接到我找到的一篇文章。(抱歉不在域内)。您可以在以下位置的文件中找到资源:

"C:\Windows\SystemResources\shell32.dll.mun"
"C:\Windows\SystemResources\imageres.dll.mun"
Run Code Online (Sandbox Code Playgroud)

Windows 10 1903 中的 imageres.dll 中不再有图标 - 4kb 文件 (superuser.com)

  • 我复制了 `shell32.dll.mun` 文件,然后使用 7-Zip **Extract Here** 并找到了我需要的图标。 (5认同)

OJ.*_*OJ. 19

另一种选择是使用ResourceHacker等工具.它处理的方式不仅仅是图标.干杯!


Sha*_*aun 9

我需要从shell32.dll中提取图标#238并且不想下载Visual Studio或Resourcehacker,所以我从Technet找到了几个PowerShell脚本(感谢John Grenfell和#https://social.technet.microsoft . com /论坛/ windowsserver/en-US/16444c7a-ad61-44a7-8c6f-b8d619381a27/using-icons-in-powershell-scripts?forum = winserverpowershell)做了类似的事情并创建了一个新的脚本(下面)以满足我的需要.

我输入的参数是(源DLL路径,目标图标文件名和DLL文件中的图标索引):

C:\ WINDOWS\SYSTEM32\SHELL32.DLL

C:\ TEMP\Restart.ico

238

我通过临时创建一个新的快捷方式(右键单击桌面并选择New - > Shortcut并输入calc并按两次Enter键)通过反复试验发现我需要的图标索引为#238.然后右键单击新快捷方式并选择"属性",然后单击"快捷方式"选项卡中的"更改图标"按钮.粘贴在路径C:\ Windows\System32\shell32.dll中,然后单击"确定".找到您要使用的图标并计算出其索引.注意:索引#2位于#1之下,而不是右侧.在我的Windows 7 x64机器上,图标索引#5位于第二列的顶部.

如果有人有一个更好的方法,工作方式相似,但获得更高质量的图标,那么我有兴趣听到它.谢谢,肖恩.

#Windows PowerShell Code###########################################################################
# http://gallery.technet.microsoft.com/scriptcenter/Icon-Exporter-e372fe70
#
# AUTHOR: John Grenfell
#
###########################################################################

<#
.SYNOPSIS
   Exports an ico and bmp file from a given source to a given destination
.Description
   You need to set the Source and Destination locations. First version of a script, I found other examples but all I wanted to do as grab and ico file from an exe but found getting a bmp useful. Others might find useful
   No error checking I'm afraid so make sure your source and destination locations exist!
.EXAMPLE
    .\Icon_Exporter.ps1
.Notes
        Version HISTORY:
        1.1 2012.03.8
#>
Param ( [parameter(Mandatory = $true)][string] $SourceEXEFilePath,
        [parameter(Mandatory = $true)][string] $TargetIconFilePath
)
CLS
#"shell32.dll" 238
If ($SourceEXEFilePath.ToLower().Contains(".dll")) {
    $IconIndexNo = Read-Host "Enter the icon index: "
    $Icon = [System.IconExtractor]::Extract($SourceEXEFilePath, $IconIndexNo, $true)    
} Else {
    [void][Reflection.Assembly]::LoadWithPartialName("System.Drawing")
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    $image = [System.Drawing.Icon]::ExtractAssociatedIcon("$($SourceEXEFilePath)").ToBitmap()
    $bitmap = new-object System.Drawing.Bitmap $image
    $bitmap.SetResolution(72,72)
    $icon = [System.Drawing.Icon]::FromHandle($bitmap.GetHicon())
}
$stream = [System.IO.File]::OpenWrite("$($TargetIconFilePath)")
$icon.save($stream)
$stream.close()
Write-Host "Icon file can be found at $TargetIconFilePath"
Run Code Online (Sandbox Code Playgroud)


小智 7

只需使用 IrfanView 打开 DLL 并将结果保存为 .gif 或 .jpg。

我知道这个问题很旧,但这是“从 dll 中提取图标”的第二次谷歌点击,我想避免在我的工作站上安装任何东西,我记得我使用 IrfanView。


Ste*_*der 5

Resources Extract是另一个工具,可以从很多DLL(非常方便的IMO)中递归地找到图标。

  • 虽然该工具非常适合提取资源,但他们还有一个工具 IconsExtract https://www.nirsoft.net/utils/iconsext.html 我觉得在大多数情况下更方便,因为我可以浏览图标并简单地链接到当我想要 Office 中嵌入/链接的文档中的图标时,系统文件。 (3认同)