我想要树图标用于本地应用程序。有谁知道如何将图像提取为.icon文件?我喜欢16x16和32x32,或者我只是做一个屏幕截图。如何从shell32.dll中获取图标?
回答
在Visual Studio中,选择“文件打开...”,然后选择“文件...”。然后选择Shell32.dll。应打开文件夹树,并在“图标”文件夹中找到图标。
要保存图标,您可以右键单击文件夹树中的图标并选择“导出”。
另一种选择是使用工具,如ResourceHacker。它处理方式不仅仅是图标。干杯!
我尝试使用Resource Hacker,但每个图标都有12个重复项(具有各种大小)。 – HighTechProgramming15 2017-01-03 13:27:42
Resources Extract是另一种从递归查找很多DLL中的图标的工具,非常方便的IMO。
只需用IrfanView打开DLL并将结果保存为.gif或.jpg。
我知道这个问题很旧,但它是第二次谷歌命中“提取图标从DLL”,我想避免在我的工作站上安装任何东西,我记得我使用IrfanView。
如果您在Linux上,可以使用gExtractWinIcons从Windows DLL中提取图标。 它在Ubuntu和Debian中的gextractwinicons
包中可用。
您可以下载免费软件Resource Hacker,然后按照下面的说明:你想从发现图标
- 打开任何一个dll文件。
- 浏览文件夹以查找特定图标。
- 从菜单栏中选择'操作',然后'保存'。
- 为.ico文件选择目的地。
参考:http://techsultan.com/how-to-extract-icons-from-windows-7/
我需要从shell32.dll中提取图标#238,不想下载Visual Studio或Resourcehacker,所以我发现一对夫妇PowerShell脚本从的Technet(感谢约翰·建富和#https://social.technet.microsoft.com/Forums/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图标指数(在桌面上单击鼠标右键,选择新建 - >快捷方式和键入calc并按Enter两次)。然后右键单击新的快捷方式并选择属性,然后在快捷方式选项卡中单击“更改图标”按钮。粘贴到路径C:\ Windows \ System32 \ shell32.dll中,然后单击确定。找到你想使用的图标并找出它的索引。注意:索引#2在#1之下,而不在右边。图标索引#5在我的Windows 7 x64机器上位于第二列的顶部。
如果任何人有一个更好的方法,同样的作品,但获得更高质量的图标,那么我会很有兴趣听到它。谢谢,肖恩。
#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"
这是以上解决方案的更新版本。 我添加了一个被隐藏在链接中的缺少的程序集。 新手不会理解这一点。 这是示例将运行没有修改。
<#
.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
.EXAMPLE
This will run but will nag you for input
.\Icon_Exporter.ps1
.EXAMPLE
this will default to shell32.dll automatically for -SourceEXEFilePath
.\Icon_Exporter.ps1 -TargetIconFilePath 'C:\temp\Myicon.ico' -IconIndexNo 238
.EXAMPLE
This will give you a green tree icon (press F5 for windows to refresh Windows explorer)
.\Icon_Exporter.ps1 -SourceEXEFilePath 'C:/Windows/system32/shell32.dll' -TargetIconFilePath 'C:\temp\Myicon.ico' -IconIndexNo 41
.Notes
Based on http://stackoverflow.com/questions/8435/how-do-you-get-the-icons-out-of-shell32-dll Version 1.1 2012.03.8
New version: Version 1.2 2015.11.20 (Added missing custom assembly and some error checking for novices)
#>
Param (
[parameter(Mandatory = $true)]
[string] $SourceEXEFilePath = 'C:/Windows/system32/shell32.dll',
[parameter(Mandatory = $true)]
[string] $TargetIconFilePath,
[parameter(Mandatory = $False)]
[Int32]$IconIndexNo = 0
)
#https://social.technet.microsoft.com/Forums/windowsserver/en-US/16444c7a-ad61-44a7-8c6f-b8d619381a27/using-icons-in-powershell-scripts?forum=winserverpowershell
$code = @"
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace System
{
public class IconExtractor
{
public static Icon Extract(string file, int number, bool largeIcon)
{
IntPtr large;
IntPtr small;
ExtractIconEx(file, number, out large, out small, 1);
try
{
return Icon.FromHandle(largeIcon ? large : small);
}
catch
{
return null;
}
}
[DllImport("Shell32.dll", EntryPoint = "ExtractIconExW", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern int ExtractIconEx(string sFile, int iIndex, out IntPtr piLargeVersion, out IntPtr piSmallVersion, int amountIcons);
}
}
"@
If (-not (Test-path -Path $SourceEXEFilePath -ErrorAction SilentlyContinue)) {
Throw "Source file [$SourceEXEFilePath] does not exist!"
}
[String]$TargetIconFilefolder = [System.IO.Path]::GetDirectoryName($TargetIconFilePath)
If (-not (Test-path -Path $TargetIconFilefolder -ErrorAction SilentlyContinue)) {
Throw "Target folder [$TargetIconFilefolder] does not exist!"
}
Try {
If ($SourceEXEFilePath.ToLower().Contains(".dll")) {
Add-Type -TypeDefinition $code -ReferencedAssemblies System.Drawing
$form = New-Object System.Windows.Forms.Form
$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())
}
} Catch {
Throw "Error extracting ICO file"
}
Try {
$stream = [System.IO.File]::OpenWrite("$($TargetIconFilePath)")
$icon.save($stream)
$stream.close()
} Catch {
Throw "Error saving ICO file [$TargetIconFilePath]"
}
Write-Host "Icon file can be found at [$TargetIconFilePath]"
如果有人正在寻找一种简单的方法,只要使用7zip的解压shell32.dll中并查找文件夹的.src/ICON/
也有这个资源可用,在Visual Studio图片库,“可用于创建与Microsoft软件看起来一致的应用程序”,可能受底层授权的约束。 https://www.microsoft.com/en-ca/download/details.aspx?id=35825
- 1. 如何创建一个dll,如包含图标的shell32.dll
- 2. DeleteFile(kernel32.dll)vs DeleteItem(shell32.dll)
- 3. MimeType从shell32中提取
- 4. 如何使用shell32.dll中从C++控制台应用程序
- 5. 如何从DLL获取HINSTANCE?
- 6. VBA - 替代使用Shell32.dll
- 7. 无法找到SHCreateItemFromParsingName(SHELL32.DLL)
- 8. P/Invoke for shell32.dll的SHMultiFileProperties
- 9. 从Shell32.dll加载图标:Win32句柄无效或类型错误
- 10. 如何从PNG图像获取图标?
- 11. 获取图标出来的DLL
- 12. 从DLL中获取HModule
- 13. 如何从图像获取坐标CGRectMake
- 14. 如何从ASP获取.NET .dll版本
- 15. Delphi 2009造成shell32.dll错误?
- 16. 我如何从.dll文件获取资源(图片)?
- 17. 如何获取NotificationListenerService中的大图标
- 18. 如何在Android中获取itouch图标?
- 19. 如何从C#中的DLL中获取类型列表?
- 20. 如何从VBA中的DLL中获取整数值?
- 21. 如何从标准中获取信息?
- 22. 从DLL获取库接口
- 23. 从资源获取dll
- 24. 从DLL/Assembly获取实例?
- 25. 从DLL/Assembly获取实例?
- 26. 从紧凑框架2.0中获取应用程序从DLL dll
- 27. 如何抓使用Shell32.SHGetFileInfo
- 28. 如何提取exe或dll文件中的图标?
- 29. 如何从MEF中提取dll文件中的图片
- 30. 如何获取图标图像
请注意,这样做违反了许可证。 “软件运行时,您可以使用但不共享其图标,图像,声音和媒体。” – 2013-03-29 22:45:06