كيف يمكنك الحصول على الرموز من shell32.dll?

StackOverflow https://stackoverflow.com/questions/8435

  •  08-06-2019
  •  | 
  •  

سؤال

أود أن أحصل على الشجرة رمز للاستخدام محلية التطبيق.لا أحد يعرف كيفية استخراج الصور النحو .أيقونة الملفات ؟ أود كلا من 16 × 16 و 32 × 32, أو كنت لا مجرد التقاط الشاشة.

هل كانت مفيدة؟

المحلول

في Visual Studio ، اختر "فتح ملف..." ثم "ملف".ثم اختيار Shell32.dll.شجرة مجلد يجب فتح و سوف تجد الرموز في "أيقونة" مجلد.

حفظ رمز ، يمكنك النقر بزر الماوس الأيمن على أيقونة في شجرة المجلد ثم اختر "تصدير".

نصائح أخرى

إذا كان أي شخص يبحث عن طريقة سهلة فقط استخدام 7zip لفك ضغط shell32.dll وابحث عن المجلد .src/رمز/

وثمة خيار آخر هو استخدام أداة مثل ResourceHacker.أنه يتعامل مع أكثر من مجرد رموز كذلك.هتاف!

أنا في حاجة إلى استخراج الرمز #238 من shell32.dll و لم ترغب في تحميل Visual Studio أو Resourcehacker لذا وجدت بعض البرامج النصية PowerShell من Technet (بفضل جون جرنفل ، #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 طريق التجربة والخطأ مؤقتا إنشاء اختصار جديد (انقر بزر الماوس الأيمن على سطح المكتب واختر جديد --> اختصار اكتب calc و اضغط Enter مرتين).ثم انقر بزر الماوس الأيمن فوق الاختصار الجديد واختر خصائص ثم انقر فوق تغيير الرمز' زر في علامة التبويب اختصار.لصق في المسار C:\Windows\System32\shell32.dll ثم انقر فوق موافق.العثور على الأيقونة التي ترغب في استخدامها والعمل بها المؤشر.ملحوظة::مؤشر #2 تحت رقم 1 و ليس لها حق.رمز مؤشر #5 كان في الجزء العلوي من العمود الثاني على ويندوز 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"

الموارد استخراج هو آخر أداة من شأنها أن متكرر تجد الرموز من الكثير من DLLs مفيد جدا في المنظمة البحرية الدولية.

هنا هو نسخة محدثة من حل أعلاه.وأضاف أنا في عداد المفقودين الجمعية الذي دفن في الرابط.المبتدئين لا أفهم ذلك.هذا هو عينة سيتم تشغيل بدون تعديلات.

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

مجرد فتح DLL مع إيرفنفيو و حفظ النتيجة كملف .gif أو .jpg.

أعرف أن هذا السؤال هو قديم ولكنه جوجل الثانية ضرب من "استخراج رمز من dll", كنت أرغب في تجنب تثبيت أي شيء على محطة العمل تذكرت استخدام إيرفنفيو.

يمكنك تحميل مجانية هاكر الموارد ثم اتبع الإرشادات أدناه :

  1. فتح أي ملف dll كنت ترغب في العثور على من الرموز.
  2. تصفح المجلدات للعثور على الرموز المحددة.
  3. من شريط القوائم ، اختر 'العمل' ثم 'حفظ'.
  4. حدد الوجهة .ملف منظمة البن الدولية.

المرجع : http://techsultan.com/how-to-extract-icons-from-windows-7/

إذا كنت على لينكس, يمكنك استخراج الرموز من Windows DLL مع gExtractWinIcons.انها متوفرة في أوبونتو دبيان في gextractwinicons الحزمة.

هذا المقال يحتوي على لقطة و شرح موجز.

هناك أيضا هذه الموارد المتاحة ، Visual Studio مكتبة الصور التي "يمكن استخدامها لإنشاء التطبيقات التي تبدو متناسقة بصريا مع برامج Microsoft" ، ويفترض أن يخضع الترخيص المعطى في الجزء السفلي.https://www.microsoft.com/en-ca/download/details.aspx?id=35825

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top