我想要樹圖標用於本地應用程序。有誰知道如何將圖像提取爲.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