<p>I'd like to get the Tree icon to use for a homegrown app.  Does anyone know how to extract the images out as .icon files? I'd like both the 16x16 and 32x32, or I'd just do a screen capture.</p>

[{'answer_id': 8436, 'author': 'jm.', 'author_id': 814, 'author_profile': 'https://Stackoverflow.com/users/814', 'pm_score': 7, 'selected': True, 'text': '<p>In Visual Studio, choose "File Open..." then "File...". Then pick the Shell32.dll. A folder tree should be opened, and you will find the icons in the "Icon" folder.</p>\n\n<p>To save an Icon, you can right-click on the icon in the folder tree and choose "Export".</p>\n'}, {'answer_id': 8450, 'author': 'OJ.', 'author_id': 611, 'author_profile': 'https://Stackoverflow.com/users/611', 'pm_score': 5, 'selected': False, 'text': '<p>Another option is to use a tool such as <a href="http://www.angusj.com/resourcehacker/" rel="noreferrer">ResourceHacker</a>. It handles way more than just icons as well. Cheers!</p>\n'}, {'answer_id': 15855337, 'author': 'Steve Cadwallader', 'author_id': 41693, 'author_profile': 'https://Stackoverflow.com/users/41693', 'pm_score': 3, 'selected': False, 'text': '<p><a href="http://www.nirsoft.net/utils/resources_extract.html" rel="noreferrer" title="Resources Extract">Resources Extract</a> is another tool that will recursively find icons from a lot of DLLs, very handy IMO.</p>\n'}, {'answer_id': 23809803, 'author': 'MannyO', 'author_id': 3665573, 'author_profile': 'https://Stackoverflow.com/users/3665573', 'pm_score': 3, 'selected': False, 'text': '<p>Just open the DLL with IrfanView and save the result as a .gif or .jpg.</p>\n\n<p>I know this question is old, but it\'s the second google hit from "extract icon from dll", I wanted to avoid installing anything on my workstation and I remembered I use IrfanView.</p>\n'}, {'answer_id': 24905798, 'author': 'Smylers', 'author_id': 1366011, 'author_profile': 'https://Stackoverflow.com/users/1366011', 'pm_score': 1, 'selected': False, 'text': '<p>If you\'re on Linux, you can extract icons from a Windows DLL with <a href="https://github.com/muflone/gextractwinicons" rel="nofollow">gExtractWinIcons</a>.\nIt\'s available in Ubuntu and Debian in the <code>gextractwinicons</code> package.</p>\n\n<p>This blog article has a <a href="http://ubuntugenius.wordpress.com/2010/07/17/how-to-extract-icons-from-exe-files-windows-programs-as-pngs-for-wine-launchers-in-ubuntu/" rel="nofollow">screenshot and brief explanation</a>.</p>\n'}, {'answer_id': 26887849, 'author': 'JohnOconor', 'author_id': 4244003, 'author_profile': 'https://Stackoverflow.com/users/4244003', 'pm_score': 2, 'selected': False, 'text': '<p>You can download freeware <a href="http://www.angusj.com/resourcehacker/" rel="nofollow">Resource Hacker</a> and then follow below instructions : </p>\n\n<ol>\n<li>Open any dll file you wish to find icons from.</li>\n<li>Browse folders to find specific icons.</li>\n<li>From menu bar, select \'action\' and then \'save\'.</li>\n<li>Select destination for .ico file.</li>\n</ol>\n\n<p>Reference : <a href="http://techsultan.com/how-to-extract-icons-from-windows-7/" rel="nofollow">http://techsultan.com/how-to-extract-icons-from-windows-7/</a></p>\n'}, {'answer_id': 28091056, 'author': 'Shaun', 'author_id': 2898010, 'author_profile': 'https://Stackoverflow.com/users/2898010', 'pm_score': 4, 'selected': False, 'text': '<p>I needed to extract icon #238 from shell32.dll and didn\'t want to download Visual Studio or Resourcehacker, so I found a couple of PowerShell scripts from Technet (thanks John Grenfell and to #<a href="https://social.technet.microsoft.com/Forums/windowsserver/en-US/16444c7a-ad61-44a7-8c6f-b8d619381a27/using-icons-in-powershell-scripts?forum=winserverpowershell">https://social.technet.microsoft.com/Forums/windowsserver/en-US/16444c7a-ad61-44a7-8c6f-b8d619381a27/using-icons-in-powershell-scripts?forum=winserverpowershell</a>) that did something similar and created a new script (below) to suit my needs.</p>\n\n<p>The parameters I entered were (the source DLL path, target icon file name and the icon index within the DLL file):</p>\n\n<p>C:\\Windows\\System32\\shell32.dll</p>\n\n<p>C:\\Temp\\Restart.ico</p>\n\n<p>238</p>\n\n<p>I discovered the icon index that I needed was #238 by trial and error by temporarily creating a new shortcut (right-click on your desktop and select New --> Shortcut and type in calc and press Enter twice).  Then right-click the new shortcut and select Properties then click \'Change Icon\' button in the Shortcut tab.  Paste in path C:\\Windows\\System32\\shell32.dll and click OK.  Find the icon you wish to use and work out its index.  NB: Index #2 is beneath #1 and not to its right.  Icon index #5 was at the top of column two on my Windows 7 x64 machine.</p>\n\n<p>If anyone has a better method that works similarly but obtains higher quality icons then I\'d be interested to hear about it.  Thanks, Shaun.</p>\n\n<pre><code>#Windows PowerShell Code###########################################################################\n# http://gallery.technet.microsoft.com/scriptcenter/Icon-Exporter-e372fe70\n#\n# AUTHOR: John Grenfell\n#\n###########################################################################\n\n&lt;#\n.SYNOPSIS\n   Exports an ico and bmp file from a given source to a given destination\n.Description\n   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\n   No error checking I\'m afraid so make sure your source and destination locations exist!\n.EXAMPLE\n    .\\Icon_Exporter.ps1\n.Notes\n        Version HISTORY:\n        1.1 2012.03.8\n#&gt;\nParam ( [parameter(Mandatory = $true)][string] $SourceEXEFilePath,\n        [parameter(Mandatory = $true)][string] $TargetIconFilePath\n)\nCLS\n#"shell32.dll" 238\nIf ($SourceEXEFilePath.ToLower().Contains(".dll")) {\n    $IconIndexNo = Read-Host "Enter the icon index: "\n    $Icon = [System.IconExtractor]::Extract($SourceEXEFilePath, $IconIndexNo, $true)    \n} Else {\n    [void][Reflection.Assembly]::LoadWithPartialName("System.Drawing")\n    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")\n    $image = [System.Drawing.Icon]::ExtractAssociatedIcon("$($SourceEXEFilePath)").ToBitmap()\n    $bitmap = new-object System.Drawing.Bitmap $image\n    $bitmap.SetResolution(72,72)\n    $icon = [System.Drawing.Icon]::FromHandle($bitmap.GetHicon())\n}\n$stream = [System.IO.File]::OpenWrite("$($TargetIconFilePath)")\n$icon.save($stream)\n$stream.close()\nWrite-Host "Icon file can be found at $TargetIconFilePath"\n</code></pre>\n'}, {'answer_id': 33835048, 'author': 'Mr. Annoyed', 'author_id': 4995131, 'author_profile': 'https://Stackoverflow.com/users/4995131', 'pm_score': 2, 'selected': False, 'text': '<p>Here is an updated version of a solution above.\nI added a missing assembly that was buried in a link.\nNovices will not understand that.\nThis is sample will run without modifications.</p>\n\n<pre><code>    &lt;#\n.SYNOPSIS\n    Exports an ico and bmp file from a given source to a given destination\n.Description\n    You need to set the Source and Destination locations. First version of a script, I found other examples \n    but all I wanted to do as grab and ico file from an exe but found getting a bmp useful. Others might find useful\n.EXAMPLE\n    This will run but will nag you for input\n    .\\Icon_Exporter.ps1\n.EXAMPLE\n    this will default to shell32.dll automatically for -SourceEXEFilePath\n    .\\Icon_Exporter.ps1 -TargetIconFilePath \'C:\\temp\\Myicon.ico\' -IconIndexNo 238\n.EXAMPLE\n    This will give you a green tree icon (press F5 for windows to refresh Windows explorer)\n    .\\Icon_Exporter.ps1 -SourceEXEFilePath \'C:/Windows/system32/shell32.dll\' -TargetIconFilePath \'C:\\temp\\Myicon.ico\' -IconIndexNo 41\n\n.Notes\n    Based on http://stackoverflow.com/questions/8435/how-do-you-get-the-icons-out-of-shell32-dll Version 1.1 2012.03.8\n    New version: Version 1.2 2015.11.20 (Added missing custom assembly and some error checking for novices)\n#&gt;\nParam ( \n    [parameter(Mandatory = $true)]\n    [string] $SourceEXEFilePath = \'C:/Windows/system32/shell32.dll\',\n    [parameter(Mandatory = $true)]\n    [string] $TargetIconFilePath,\n    [parameter(Mandatory = $False)]\n    [Int32]$IconIndexNo = 0\n)\n\n#https://social.technet.microsoft.com/Forums/windowsserver/en-US/16444c7a-ad61-44a7-8c6f-b8d619381a27/using-icons-in-powershell-scripts?forum=winserverpowershell\n$code = @"\nusing System;\nusing System.Drawing;\nusing System.Runtime.InteropServices;\n\nnamespace System\n{\n    public class IconExtractor\n    {\n\n     public static Icon Extract(string file, int number, bool largeIcon)\n     {\n      IntPtr large;\n      IntPtr small;\n      ExtractIconEx(file, number, out large, out small, 1);\n      try\n      {\n       return Icon.FromHandle(largeIcon ? large : small);\n      }\n      catch\n      {\n       return null;\n      }\n\n     }\n     [DllImport("Shell32.dll", EntryPoint = "ExtractIconExW", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]\n     private static extern int ExtractIconEx(string sFile, int iIndex, out IntPtr piLargeVersion, out IntPtr piSmallVersion, int amountIcons);\n\n    }\n}\n"@\n\nIf  (-not (Test-path -Path $SourceEXEFilePath -ErrorAction SilentlyContinue ) ) {\n    Throw "Source file [$SourceEXEFilePath] does not exist!"\n}\n\n[String]$TargetIconFilefolder = [System.IO.Path]::GetDirectoryName($TargetIconFilePath) \nIf  (-not (Test-path -Path $TargetIconFilefolder -ErrorAction SilentlyContinue ) ) {\n    Throw "Target folder [$TargetIconFilefolder] does not exist!"\n}\n\nTry {\n    If ($SourceEXEFilePath.ToLower().Contains(".dll")) {\n        Add-Type -TypeDefinition $code -ReferencedAssemblies System.Drawing\n        $form = New-Object System.Windows.Forms.Form\n        $Icon = [System.IconExtractor]::Extract($SourceEXEFilePath, $IconIndexNo, $true)    \n    } Else {\n        [void][Reflection.Assembly]::LoadWithPartialName("System.Drawing")\n        [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")\n        $image = [System.Drawing.Icon]::ExtractAssociatedIcon("$($SourceEXEFilePath)").ToBitmap()\n        $bitmap = new-object System.Drawing.Bitmap $image\n        $bitmap.SetResolution(72,72)\n        $icon = [System.Drawing.Icon]::FromHandle($bitmap.GetHicon())\n    }\n} Catch {\n    Throw "Error extracting ICO file"\n}\n\nTry {\n    $stream = [System.IO.File]::OpenWrite("$($TargetIconFilePath)")\n    $icon.save($stream)\n    $stream.close()\n} Catch {\n    Throw "Error saving ICO file [$TargetIconFilePath]"\n}\nWrite-Host "Icon file can be found at [$TargetIconFilePath]"\n</code></pre>\n'}, {'answer_id': 37801676, 'author': 'AQN', 'author_id': 6462210, 'author_profile': 'https://Stackoverflow.com/users/6462210', 'pm_score': 6, 'selected': False, 'text': '<p>If anyone is seeking an easy way, just use 7zip to unzip the shell32.dll and look for the folder .src/ICON/</p>\n'}, {'answer_id': 42963528, 'author': 'David Carr', 'author_id': 695807, 'author_profile': 'https://Stackoverflow.com/users/695807', 'pm_score': 2, 'selected': False, 'text': '<p>There is also this resource available, the Visual Studio Image Library, which "can be used to create applications that look visually consistent with Microsoft software", presumably subject to the licensing given at the bottom.\n<a href="https://www.microsoft.com/en-ca/download/details.aspx?id=35825" rel="nofollow noreferrer">https://www.microsoft.com/en-ca/download/details.aspx?id=35825</a></p>\n'}, {'answer_id': 67446002, 'author': 'i Mr Oli i', 'author_id': 11199164, 'author_profile': 'https://Stackoverflow.com/users/11199164', 'pm_score': 2, 'selected': False, 'text': '<p>This question already has answers here, but for anybody new wondering how to do this, I used 7Zip and navigated to <code>%SystemRoot%\\system32\\SHELL32.dll\\.rsrc\\ICON</code>, then copied all the files to a desired location.</p>\n<p>If you\'d like a pre-extracted directory, you can <a href="https://github.com/imrolii/SiteDownloads/raw/main/Shell32.zip" rel="nofollow noreferrer">download the ZIP here</a>.</p>\n<p>Note: I extracted the files on a Windows 8.1 installation, so they may vary from the ones on other versions of Windows.</p>\n'}, {'answer_id': 71200876, 'author': 'TheManInOz', 'author_id': 11959950, 'author_profile': 'https://Stackoverflow.com/users/11959950', 'pm_score': 4, 'selected': False, 'text': '<p>Not sure if I am 100% correct, but from my testing, the above options for using 7Zip or VS don\'t work on Windows 10 / 11 versions of imageres.dll or shell32.dll.\nThis is the content I see:</p>\n<pre><code>[shell32.dll]\n.rsrc\\MANIFEST\\124\n.rsrc\\MUI\\1\n.rsrc\\TYPELIB\\1\n.rsrc\\version.txt\n.data\n.didat\n.pdata\n.rdata\n.reloc\n.text\nCERTIFICATE\n</code></pre>\n<p>Update: And I think I found why. Link to an article I found. (Sorry for being off-domain).\nYou can find the resources in files in these locations:</p>\n<pre><code>&quot;C:\\Windows\\SystemResources\\shell32.dll.mun&quot;\n&quot;C:\\Windows\\SystemResources\\imageres.dll.mun&quot;\n</code></pre>\n<p><a href="https://superuser.com/questions/1480268/icons-no-longer-in-imageres-dll-in-windows-10-1903-4kb-file">Icons no longer in imageres.dll in Windows 10 1903 - 4kb file (superuser.com)</a></p>\n'}]
['https://Stackoverflow.com/questions/8435', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/733/']