Pregunta

Me gustaría obtener el ícono del Árbol para usarlo en una aplicación local.¿Alguien sabe cómo extraer las imágenes como archivos .icon?Me gustaría tanto el 16x16 como el 32x32, o simplemente haría una captura de pantalla.

¿Fue útil?

Solución

En Visual Studio, elija "Archivo Abrir..." y luego "Archivo...".Luego elija Shell32.dll.Se debe abrir un árbol de carpetas y encontrará los iconos en la carpeta "Icono".

Para guardar un ícono, puede hacer clic derecho en el ícono en el árbol de carpetas y elegir "Exportar".

Otros consejos

Si alguien busca una manera fácil, simplemente use 7zip para descomprimir shell32.dll y busque la carpeta .src/ICON/

Otra opción es utilizar una herramienta como hacker de recursos.También maneja mucho más que solo íconos.¡Salud!

Necesitaba extraer el ícono #238 de shell32.dll y no quería descargar Visual Studio o Resourcehacker, así que encontré un par de scripts de PowerShell de Technet (gracias John Grenfell y a #https://social.technet.microsoft.com/Forums/windowsserver/en-US/16444c7a-ad61-44a7-8c6f-b8d619381a27/using-icons-in-powershell-scripts?forum=winserverpowershell) que hizo algo similar y creó un nuevo script (a continuación) para satisfacer mis necesidades.

Los parámetros que ingresé fueron (la ruta de la DLL de origen, el nombre del archivo del icono de destino y el índice del icono dentro del archivo DLL):

C:\Windows\System32\shell32.dll

C: emp einiciar.ico

238

Descubrí que el índice de iconos que necesitaba era el n.° 238 mediante prueba y error al crear temporalmente un nuevo acceso directo (haga clic con el botón derecho en su escritorio y seleccione Nuevo --> Acceso directo, escriba calc y presione Entrar dos veces).Luego haga clic derecho en el nuevo acceso directo y seleccione Propiedades, luego haga clic en el botón 'Cambiar icono' en la pestaña Acceso directo.Pegue la ruta C:\Windows\System32\shell32.dll y haga clic en Aceptar.Busque el icono que desea utilizar y determine su índice.NÓTESE BIEN:El índice n.° 2 está debajo del n.° 1 y no a su derecha.El índice de iconos n.° 5 estaba en la parte superior de la columna dos en mi máquina con Windows 7 x64.

Si alguien tiene un método mejor que funcione de manera similar pero obtenga íconos de mayor calidad, me interesaría conocerlo.Gracias, Shaun.

#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"

Extracto de recursos es otra herramienta que buscará recursivamente íconos de muchas DLL, lo cual es muy útil en mi opinión.

Aquí hay una versión actualizada de una solución anterior.Agregué un ensamblaje faltante que estaba enterrado en un enlace.Los novatos no entenderán eso.Esta es una muestra que se ejecutará sin modificaciones.

    <#
.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]"

Simplemente abra la DLL con IrfanView y guarde el resultado como .gif o .jpg.

Sé que esta pregunta es antigua, pero es la segunda vez que Google accede a "extraer icono de dll". Quería evitar instalar nada en mi estación de trabajo y recordé que uso IrfanView.

Puedes descargar software gratuito Hacker de recursos y luego siga las siguientes instrucciones:

  1. Abra cualquier archivo dll del que desee buscar iconos.
  2. Explore carpetas para encontrar íconos específicos.
  3. Desde la barra de menú, seleccione "acción" y luego "guardar".
  4. Seleccione el destino para el archivo .ico.

Referencia : http://techsultan.com/how-to-extract-icons-from-windows-7/

Si está en Linux, puede extraer iconos de una DLL de Windows con gExtractWinIconos.Está disponible en Ubuntu y Debian en el gextractwinicons paquete.

Este artículo de blog tiene un captura de pantalla y breve explicación.

También está disponible este recurso, la Biblioteca de imágenes de Visual Studio, que "puede usarse para crear aplicaciones que parezcan visualmente consistentes con el software de Microsoft", presumiblemente sujeto a la licencia que se proporciona en la parte inferior.https://www.microsoft.com/en-ca/download/details.aspx?id=35825

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top