Results 1 to 2 of 2

Thread: [DELPHI] - Extract Icon

  1. #1

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    [DELPHI] - Extract Icon

    Code:
    uses
      shellApi;
    
    procedure TForm1.Button1Click(Sender: TObject);
    const
      ExtrFileName = {Enter FileName.dll here};
    var
      icon: TIcon;
      NumberOfIcons, i: Integer;
    begin
      icon := TIcon.Create;
      try
        // Get the number of Icons
        NumberOfIcons := ExtractIcon(Handle, PChar(ExtrFileName), UINT(-1));
        ShowMessage(Format('%d Icons', [NumberOfIcons]));
        // Extract the first 5 icons of DLL
        for i := 1 to 5 do
        begin
          // Extract an icon
          icon.Handle := ExtractIcon(Handle, PChar(ExtrFileName), i);
          // Draw the icon on your form
          DrawIcon(Form1.Canvas.Handle, 10, i * 40, icon.Handle);
        end;
      finally
        icon.Free;
      end;
    end;

  2. #2

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: [DELPHI] - Extract Icon

    Simplified Method:

    Code:
    Uses, ShellAPI
    
    procedure ExtractIcon; 
    begin 
      image1.picture.Icon.Handle:=extracticon(application.Handle,'C:\Windows\System\Shell32.dll',10); 
    end; 
    
    Change the 10 (index of file) to another integer. For example, setting it to:
    
    image1.picture.Icon.Handle:=extracticon(application.Handle,'C:\Windows\System\Shell32.dll',5); 
    end; 
    
    will retrieve the 5th icon from the dll

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width