Pergunta

Gostaria de obter a Árvore ícone para usar para um homegrown app.Alguém sabe como extrair imagens como .arquivos de ícone?Eu gostaria tanto de 16x16 e 32x32, ou eu tinha acabado de fazer uma captura de tela.

Foi útil?

Solução

No Visual Studio, escolha "Abrir Arquivo..." e depois em "Arquivo...".Em seguida, escolher o Shell32.dll.Uma árvore de pasta deve ser aberta, e você vai encontrar os ícones no "Ícone" pasta.

Para salvar um Ícone, você pode clique com o botão direito do mouse sobre o ícone na árvore de pastas e clique em "Exportar".

Outras dicas

Se alguém está procurando uma maneira fácil, basta usar o 7zip para descompactar o shell32.dll e procure a pasta .src/ICON/

Outra opção é usar uma ferramenta como o ResourceHacker.Ele lida de maneira mais do que apenas ícones.Saúde!

Eu precisava extrair ícone #238 de shell32.dll e não queria baixar o Visual Studio ou Resourcehacker, então, eu encontrei um par de scripts do PowerShell do Technet (graças John Grenfell e a #https://social.technet.microsoft.com/Forums/windowsserver/en-US/16444c7a-ad61-44a7-8c6f-b8d619381a27/using-icons-in-powershell-scripts?forum=winserverpowershell) que fez algo semelhante e criou um novo script (abaixo), para atender as minhas necessidades.

Os parâmetros que foram inseridos (a origem do caminho da DLL, ícone de destino nome do arquivo e o índice do ícone dentro do arquivo DLL):

C:\Windows\System32\shell32.dll

C: emp estart.ico

238

Eu descobri o índice de ícone que eu precisava era de #238 por tentativa e erro, temporariamente, a criação de um novo atalho (clique com o botão direito do mouse na área de trabalho e selecione Novo - > Atalho e digite no calc e prima Enter duas vezes).Em seguida, clique com o botão direito do mouse no novo atalho e selecione Propriedades e, em seguida, clique em "Alterar Ícone' na guia Atalho.Cole no caminho C:\Windows\System32\shell32.dll e clique em OK.Encontre o ícone que você deseja usar e trabalhar fora do seu índice.NB:Índice #2 está abaixo #1 e não o seu direito.Índice de ícone do #5 estava no topo da coluna dois no meu Windows 7 x64 máquina.

Se alguém tiver uma melhor método que funciona de forma semelhante, mas obtém maior qualidade ícones então eu estaria interessado em ouvir sobre isso.Obrigado, 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"

Recursos Extrair é outra ferramenta que irá recursivamente encontrar ícones de um monte de Dll, muito útil IMO.

Aqui está uma versão atualizada de uma solução acima.Eu adicionei uma falta de montagem que foi enterrado em um link.Novatos não vão entender isso.Este é o exemplo será executado sem modificações.

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

Basta abrir a DLL com o IrfanView e salvar o resultado como um .ou gif .jpg.

Eu sei que essa pergunta é velha, mas é a segunda google hit de "extrair ícone da dll", que eu queria evitar instalar nada na minha estação de trabalho e lembrei-me que eu uso o IrfanView.

Você pode fazer o download de freeware Resource Hacker e, em seguida, siga as instruções abaixo :

  1. Abra qualquer arquivo dll que você quer encontrar os ícones.
  2. Procurar pastas para encontrar ícones específicos.
  3. A partir da barra de menu, selecione 'ação' e depois em 'salvar'.
  4. Selecione destino .esse arquivo.

Referência : http://techsultan.com/how-to-extract-icons-from-windows-7/

Se você estiver no Linux, você pode extrair ícones de uma DLL do Windows com gExtractWinIcons.Ele está disponível no Ubuntu e no Debian gextractwinicons pacote.

Este blog tem um artigo captura de tela e breve explicação.

Também existe o recurso disponível, o Visual Studio Image Library, o qual "pode ser usado para criar aplicativos que parecem visualmente consistente com o Microsoft software", presumivelmente assunto para o licenciamento dado na parte inferior.https://www.microsoft.com/en-ca/download/details.aspx?id=35825

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top