Class IconExe


  • public class IconExe
    extends java.lang.Object
    Customize the icon of a Windows exe

    WARNING! This class is not part of SWT API. It is NOT API. It is an internal tool that may be changed or removed at anytime.

    Based on MSDN "An In-Depth Look into the Win32 Portable Executable File Format".

    Win x64 support (Bug #238001) based on MSDN "x64 Primer: Everything You Need To Know To Start Programming 64-Bit Windows Systems".

    • Constructor Detail

      • IconExe

        public IconExe()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Replace the Desktop icons provided in the Windows executable program with matching icons provided by the user.

        Takes 2 arguments argument 0: the Windows executable e.g c:/eclipse/eclipse.exe argument 1: The .ico file to write to the given executable e.g. c:/myApp.ico

        Note 1. Write access to the executable program is required. As a result, that program must not be currently running or edited elsewhere.

        Note 2. The Eclipse 3.4 launcher requires an .ico file with the following 7 images (in any order). 1. 48x48, 32 bit (RGB / Alpha Channel) 2. 32x32, 32 bit (RGB / Alpha Channel) 3. 16x16, 32 bit (RGB / Alpha Channel) 4. 48x48, 8 bit (256 colors) 5. 32x32, 8 bit (256 colors) 6. 24x24, 8 bit (256 colors) 7. 16x16, 8 bit (256 colors)

        Note 3. The Eclipse 4.2 launcher requires an .ico file with the following 7 images (in any order). 1. 256x256, 32 bit (RGB / Alpha Channel) 2. 48x48, 32 bit (RGB / Alpha Channel) 3. 32x32, 32 bit (RGB / Alpha Channel) 4. 16x16, 32 bit (RGB / Alpha Channel) 5. 48x48, 8 bit (256 colors) 6. 32x32, 8 bit (256 colors) 7. 16x16, 8 bit (256 colors)

        A user icon matching exactly the width/height/depth of an executable icon will be written to the executable and will replace that executable icon. If an executable icon does not match a user icon, it is silently left as is.

        Note 4. This function modifies the content of the executable program and may cause its corruption.

        Parameters:
        args - woo
        Throws:
        java.lang.Exception - www
        java.io.IOException - eee
      • setIcon

        public static void setIcon​(java.io.File exe,
                                   java.lang.String resourcePath)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setIcon

        public static void setIcon​(java.io.File exe,
                                   java.io.File ico)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • exeIconsFromPng

        public static java.util.List<daevil.iconexe.IconExe.ImageData> exeIconsFromPng​(java.lang.String program,
                                                                                       java.lang.Object imgFile)
                                                                                throws java.io.IOException
        nasty little deal to create matching exe images from a png file
        Parameters:
        program - the Windows executable e.g c:/eclipse/eclipse.exe
        imgFile - png file (256x256) to create icons from
        Returns:
        icons matching format for those in the executable
        Throws:
        java.io.IOException - io error
      • getBuff

        public static java.awt.image.BufferedImage getBuff​(daevil.iconexe.IconExe.ImageData data)
      • copyFile

        public static void copyFile​(java.lang.String src,
                                    java.lang.String dst)
                             throws java.io.FileNotFoundException,
                                    java.io.IOException
        Throws:
        java.io.FileNotFoundException
        java.io.IOException