문제

자체 개발 앱에 사용할 트리 아이콘을 얻고 싶습니다.이미지를 .icon 파일로 추출하는 방법을 아는 사람이 있나요?16x16과 32x32를 모두 원하거나 화면 캡처를 하고 싶습니다.

도움이 되었습니까?

해결책

Visual Studio에서 "파일 열기..."를 선택한 다음 "파일..."을 선택합니다.그런 다음 Shell32.dll을 선택합니다.폴더 트리가 열리고 "아이콘" 폴더에서 아이콘을 찾을 수 있습니다.

아이콘을 저장하려면 폴더 트리에서 아이콘을 마우스 오른쪽 버튼으로 클릭하고 "내보내기"를 선택하세요.

다른 팁

누구든지 쉬운 방법을 찾고 있다면 7zip을 사용하여 shell32.dll의 압축을 풀고 .src/ICON/ 폴더를 찾으세요.

또 다른 옵션은 다음과 같은 도구를 사용하는 것입니다. 리소스해커.아이콘 이상의 기능도 처리합니다.건배!

shell32.dll에서 아이콘 #238을 ​​추출해야 했지만 Visual Studio나 Resourcehacker를 다운로드하고 싶지 않았기 때문에 Technet에서 몇 가지 PowerShell 스크립트를 찾았습니다(John Grenfell과 #에게 감사드립니다).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: emp estart.ico

238

일시적으로 새로운 바로가기를 생성하여 시행착오를 거쳐 필요한 아이콘 색인이 #238이라는 것을 발견했습니다(바탕 화면에서 마우스 오른쪽 버튼을 클릭하고 새로 만들기 --> 바로가기를 선택하고 계산을 입력하고 Enter를 두 번 누릅니다).그런 다음 새 바로가기를 마우스 오른쪽 버튼으로 클릭하고 속성을 선택한 다음 바로가기 탭에서 '아이콘 변경' 버튼을 클릭하세요.C:\Windows\System32\shell32.dll 경로를 붙여넣고 확인을 클릭합니다.사용하려는 아이콘을 찾아 해당 색인을 작성하세요.참고:인덱스 #2는 #1 아래에 있고 오른쪽에 있지 않습니다.아이콘 인덱스 #5는 내 Windows 7 x64 시스템에서 열 2의 맨 위에 있었습니다.

비슷하게 작동하지만 더 높은 품질의 아이콘을 얻는 더 나은 방법이 있는 사람이 있다면 이에 대해 듣고 싶습니다.고마워요, 숀.

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

자원 추출 매우 편리한 IMO인 많은 DLL에서 아이콘을 재귀적으로 찾는 또 다른 도구입니다.

위 솔루션의 업데이트된 버전은 다음과 같습니다.링크에 묻혀 있던 누락된 어셈블리를 추가했습니다.초보자는 그것을 이해하지 못할 것입니다.이 샘플은 수정 없이 실행됩니다.

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

IrfanView로 DLL을 열고 결과를 .gif 또는 .jpg로 저장하면 됩니다.

이 질문은 오래되었다는 것을 알고 있지만 "dll에서 아이콘 추출"에 대한 Google의 두 번째 히트작입니다. 워크스테이션에 아무것도 설치하지 않으려고 IrfanView를 사용한다는 것을 기억했습니다.

프리웨어를 다운로드할 수 있습니다 리소스 해커 그런 다음 아래 지침을 따르십시오.

  1. 아이콘을 찾으려는 dll 파일을 엽니다.
  2. 특정 아이콘을 찾으려면 폴더를 탐색하세요.
  3. 메뉴 표시줄에서 '작업'을 선택한 다음 '저장'을 선택하세요.
  4. .ico 파일의 대상을 선택하세요.

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

Linux를 사용하는 경우 다음을 사용하여 Windows DLL에서 아이콘을 추출할 수 있습니다. gExtractWinIcons.우분투와 데비안에서 사용할 수 있습니다. gextractwinicons 패키지.

이 블로그 기사에는 스크린샷과 간단한 설명.

또한 "Microsoft 소프트웨어와 시각적으로 일관되게 보이는 응용 프로그램을 만드는 데 사용할 수 있는" Visual Studio 이미지 라이브러리라는 리소스도 있습니다. 이는 아마도 하단에 제공된 라이센스에 따라 달라질 수 있습니다.https://www.microsoft.com/en-ca/download/details.aspx?id=35825

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top