Я хочу, чтобы значок Tree использовался для домашнего приложения. Кто-нибудь знает, как извлечь изображения в виде .icon файлов? Мне бы хотелось как 16x16, так и 32x32, или я просто сделаю захват экрана.
Как вы получаете значки из shell32.dll?
Ответ 1
В Visual Studio выберите "Файл Открыть...", затем "Файл...". Затем выберите Shell32.dll. Необходимо открыть дерево папок, и вы найдете значки в папке "Значок".
Чтобы сохранить значок, вы можете щелкнуть правой кнопкой мыши по значку в дереве папок и выбрать "Экспорт".
Ответ 2
Если кто-то ищет простой способ, просто используйте 7zip для распаковки shell32.dll и найдите папку .src/ICON/
Ответ 3
Другой вариант - использовать такой инструмент, как ResourceHacker. Он обрабатывает больше, чем просто значки. Ура!
Ответ 4
Мне нужно было извлечь значок # 238 из shell32.dll и не захотеть загружать Visual Studio или Resourcehacker, поэтому я нашел пару скриптов PowerShell от Technet (спасибо John Grenfell и # https://social.technet.microsoft.com/Forums/windowsserver/en-US/16444c7a-ad61-44a7-8c6f-b8d619381a27/using-icons-in-powershell-scripts?forum=winserverpowershell), который сделал что-то подобное и создал новый script (ниже) в соответствии с моими потребностями.
Параметры, которые я ввел, были (исходный путь к DLL, имя файла значка цели и индекс значка в DLL файле):
C:\Windows\System32\shell32.dll
C:\Temp\Restart.ico
238
Я обнаружил, что индекс значков, который мне нужен, был # 238 методом проб и ошибок, временно создавая новый ярлык (щелкните правой кнопкой мыши на рабочем столе и выберите "Создать" → "Ярлык" и введите "calc" и нажмите "Enter" дважды). Затем щелкните правой кнопкой мыши новый ярлык и выберите "Свойства", затем нажмите кнопку "Изменить значок" на вкладке "Ярлык". Вставьте путь C:\Windows\System32\shell32.dll и нажмите "ОК". Найдите значок, который вы хотите использовать, и отработайте его индекс. NB: Индекс №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"
Ответ 5
Извлечение ресурсов - это еще один инструмент, который будет рекурсивно находить значки из многих библиотек DLL, что очень удобно для IMO.
Ответ 6
Ниже приведена обновленная версия решения выше. Я добавил отсутствующую сборку, которая была похоронена в ссылке. Новички этого не поймут. Этот образец будет работать без изменений.
<#
.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]"
Ответ 7
Просто откройте DLL с помощью IrfanView и сохраните результат как .gif или .jpg.
Я знаю, что этот вопрос старый, но это второй google-хит из "extract icon from dll", я не хотел ничего устанавливать на своей рабочей станции, и я вспомнил, что я использую IrfanView.
Ответ 8
Вы можете скачать бесплатное Resource Hacker, а затем следовать инструкциям ниже:
- Откройте любой DLL файл, из которого вы хотите найти значки.
- Обзор папок для поиска определенных значков.
- В строке меню выберите "действие", а затем "сохранить".
- Выберите пункт назначения для файла .ico.
Ссылка: http://techsultan.com/how-to-extract-icons-from-windows-7/
Ответ 9
Если вы работаете в Linux, вы можете извлекать значки из Windows DLL с gExtractWinIcons.
Он доступен в Ubuntu и Debian в пакете gextractwinicons
.
В этой статье в блоге снимок экрана и краткое объяснение.
Ответ 10
Имеется также этот доступный ресурс - Библиотека изображений Visual Studio, которая "может использоваться для создания приложений, которые выглядят визуально в соответствии с программным обеспечением Microsoft", предположительно, под лицензией, приведенной внизу. https://www.microsoft.com/en-ca/download/details.aspx?id=35825