Jump to content

Compile multiple .ico files into one .dll file


Inpho
 Share

Recommended Posts

So after many weekends of battling with this I finally figured it; then I automated it.

This script includes icon sushi (which is used to remove the 256 x 256 elements from each .ico) and RDG (to compile the icons into dll).

I had to idiot proof this for when I inevitably forget how to do it. First GUI will ask you to choose a name (among other things) for your .dll file. Next GUI is a drag-and-drop box. Drag-and-drop your .ico files into the box and click Go. Error checking is minimal; it works fine for me but YRMV. I'm no master programmer at all but if this script can help you as much as it helped me then cool.

Download:  ico2dll.Exe

Known issues:

.ico's containing any layers larger than 256 x 256 px will be ignored by icon sushi

ico2dll only registers one drag-and-drop event so put all your required icons into one folder; then drag-and-drop them into ico2dll

Extra info:

Basically, the RC.exe that is included with Visual Studio doesn't seem to support 256 x 256 or larger icons when creating a resource-only .dll file. This script uses icon sushi to remove all 256 x 256 elements from your .ico files (if your icon file contains any layers larger than 256 x 256 then you will have to remove those manually through a program like gimp) before compiling them into the .dll.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\ICONS\Capital18-Ethereal-2-Mimetypes-dll.ico
#AutoIt3Wrapper_Outfile=ico2dll.Exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiEdit.au3>
#include <File.au3>
#include <Misc.au3>
#include <Array.au3>

Opt("trayicondebug", 1)
$tmp = "C:\ico2dlltemp\"
$tmprmv = "C:\ico2dlltemp\rmv\"
If FileExists($tmp) Then DirRemove($tmp, 1)
Sleep(100)
DirCreate($tmprmv)

Global $FileName, $ListViewIndexSel = -1, $PathAllExist, $RCFile, $vpath
Global $szDrive, $szDir, $szFName, $szExt, $dBox, $iData, $vdata2, $lang, $iData2
Global $TmpDir = @TempDir & "\ResDllGen"
Global $TmpDirplusSlash = @TempDir & "\ResDllGen\"
Global $Res_List, $Res_Name, $Res_Type, $Res_Path, $StrLenPath, $Bloc, $LangHex

If FileExists($TmpDir) Then DirRemove($TmpDir, 1)
If FileExists($TmpDirplusSlash) Then DirRemove($TmpDirplusSlash, 1)
Sleep(100)
DirCreate($TmpDirplusSlash)
$rnd = Random(999, 99999, 1)

DirCreate(@ScriptDir & "\tools\")
DirCreate(@ScriptDir & "\Languages\")

FileInstall("aicon.exe", @ScriptDir & "\aicon.exe")
FileInstall("aicon.ini", @ScriptDir & "\aicon.ini")
FileInstall("brushes", @ScriptDir & "\brushes")
FileInstall("Languages\English.lng", @ScriptDir & "\Languages\English.lng")
FileInstall("Languages\“ú–{Œê.lng", @ScriptDir & "\Languages\“ú–{Œê.lng")
FileInstall("Languages\Default.lng", @ScriptDir & "\Languages\Default.lng")

;FileInstall("G:\autoo\resdll\generator\RDG.exe", @ScriptDir & "\RDG.exe")
FileInstall("tools\cvtres.exe", @ScriptDir & "\tools\cvtres.exe")
FileInstall("tools\DLLSZ.ico", @ScriptDir & "\tools\DLLSZ.ico")
FileInstall("tools\link.exe", @ScriptDir & "\tools\link.exe")
FileInstall("tools\mspdb50.dll", @ScriptDir & "\tools\mspdb50.dll")
FileInstall("tools\rc.exe", @ScriptDir & "\tools\rc.exe")
FileInstall("tools\RCdll.dll", @ScriptDir & "\tools\RCdll.dll")
Const $SP = "#~#"
Dim $Lang
_SelectLanguage()

$Res_Gui_2 = GUICreate($lang[22], 390, 470, -1, -1, -1) ; DLL Info
$FileVersion_Title = GUICtrlCreateLabel($lang[23] & " :", 110, 8, 171, 28) ; DLL Informations
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel($lang[24], 15, 60, 125, 20) ; Dll Filename
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Dll_File_Name = GUICtrlCreateInput($lang[25], 175, 60, 140, 21) ; MyDll
GUICtrlCreateLabel(".Dll", 318, 63, 30, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel($lang[26], 16, 92, 130, 20) ; File Version
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Dll_Ver1 = GUICtrlCreateInput("01", 175, 92, 35, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
$UpD1 = GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 99, 01)
$Dll_Ver2 = GUICtrlCreateInput("00", 220, 92, 35, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
$UpD2 = GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 99)
$Dll_Ver3 = GUICtrlCreateInput("0000", 265, 92, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
$UpD3 = GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 9999)
$Dll_Ver4 = GUICtrlCreateInput("0000", 325, 92, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
$UpD4 = GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 9999)
GUICtrlCreateLabel($lang[27], 16, 127, 150, 20) ; Product Version
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Dll_PVer1 = GUICtrlCreateLabel("01,00,0000,0000", 175, 130, 90, 20)
$Dll_PVer2 = GUICtrlCreateInput("", 265, 127, 110, 21)
GUICtrlCreateLabel($lang[28], 16, 165, 150, 20) ; Product Name
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Dll_Prod_Name = GUICtrlCreateInput($lang[29], 175, 165, 200, 21) ; Name_Of_Your_Product
GUICtrlCreateLabel($lang[30], 16, 200, 150, 20) ; Compagny Name
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Dll_Compagny = GUICtrlCreateInput($lang[31], 175, 200, 200, 21) ; Type_Your_Company
GUICtrlCreateLabel($lang[32], 16, 235, 150, 20) ; Legal Copyright
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Dll_Copyright = GUICtrlCreateInput($lang[33], 175, 235, 200, 21) ; Copyright_(C)_2007-2008
GUICtrlCreateLabel($lang[34], 16, 270, 150, 20) ; File Description
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Dll_File_Desc = GUICtrlCreateInput($lang[35], 175, 270, 200, 21) ; Type_Your_Description
GUICtrlCreateLabel($lang[36], 16, 305, 150, 20) ; Language
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Dll_Lang = GUICtrlCreateCombo("", 175, 305, 90, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $lang[37], $lang[38]) ; English|French ; English
; See http://msdn.microsoft.com/en-us/library/aa381058%28VS.85%29.aspx for value.
GUICtrlCreateLabel($lang[39], 16, 340, 150, 20) ; File OS
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Dll_OS = GUICtrlCreateCombo("", 175, 340, 90, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $lang[40], $lang[41]) ; 0x40004 ; 0x40004
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel($lang[42], 16, 375, 150, 20) ; File Type
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Dll_File_Type = GUICtrlCreateCombo("", 175, 375, 90, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $lang[43], $lang[44]) ; 0x2 ; 0x2
GUICtrlSetState(-1, $GUI_DISABLE)
$Btn_OK2 = GUICtrlCreateButton($lang[45], 160, 432, 75, 25) ; OK

GUISetState(@SW_SHOW, $Res_Gui_2)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $Btn_OK2
            If GUICtrlRead($Dll_File_Name) = $lang[25] Then ; MyDll
                MsgBox(32 + 8192, $lang[53], $lang[54] & @TAB) ; Dll File Name ; Please, Enter The Name Of Your Dll
                GUICtrlSetState($Dll_File_Name, $GUI_FOCUS)
            Else
                GUICtrlSetData($Dll_File_Name, StringReplace(GUICtrlRead($Dll_File_Name), " ", "_"))
                SetDllData()
                GUIDelete($Res_Gui_2)
                AddIcons()
            EndIf
        Case $UpD1, $UpD2, $UpD3, $UpD4
            _UpdateVerNum()
        Case $GUI_EVENT_PRIMARYDOWN
            _UpdateVerNum()
        Case $GUI_EVENT_CLOSE
            TraySetState(2)
            Exit
    EndSwitch
WEnd

Func AddIcons()
    Global $__aGUIDropFiles = 0, $aDrop_List = 0
    Global $txtInput = "Drag and drop your .ico files here"
    $mGUI = GUICreate("ico2dll", 900, 400, -1, -1, "", $WS_EX_ACCEPTFILES)
    $dBox = GUICtrlCreateEdit($txtInput, 10, 10, 874, 300)
    GUICtrlSetState($dBox, $GUI_DROPACCEPTED)
    $gBut = GUICtrlCreateButton("Go", 10, 320, 75, 25)
    $eBut = GUICtrlCreateButton("Exit", 810, 320, 75, 25)
    GUISetState()
    GUIRegisterMsg($WM_DROPFILES, 'On_WM_DROPFILES')
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                TraySetState(2)
                DirRemove($tmp, 1)
                Exit
            Case $eBut
                TraySetState(2)
                DirRemove($tmp, 1)
                Exit
            Case $GUI_EVENT_DROPPED
                GUICtrlSetData($dBox, "")
                For $i = 1 To $aDrop_List[0]
                    $old = GUICtrlRead($dBox)
                    $new = $old & $aDrop_List[$i] & @CRLF
                    GUICtrlSetData($dBox, $new)
                Next
            Case $gBut
                $check = GUICtrlRead($dBox)
                If $check = $txtInput Then
                    MsgBox(0, "Error", "You must drag-and-drop some .ico files into the box")
                    ContinueLoop
                Else
                    $iData = StringSplit($check, @LF)
                EndIf
                GUIDelete($mGUI)
                _MouseTrap(0, 0, 1, 1)
                CopyTemp()
                Rmv256()
                GenDll()
                _MouseTrap()
        EndSwitch
    WEnd
EndFunc   ;==>AddIcons

Func Rmv256()
    DirCreate($tmprmv)
    IniWrite(@ScriptDir & "\aicon.ini", "Option", "ListViewMode", "0")
    IniWrite(@ScriptDir & "\aicon.ini", "Option", "InitialDir", "C:\ico2dlltemp")
    Global $PID2 = ""
    $last = "placeholder"
    $Amow = 100
    $hWnd2 = ""
    $aPID = Run(@ScriptDir & "\aicon.exe")
    WinWaitActive("@icon sushi", "", 10)
    $theWinlist = WinList()
    Do
        For $i = 1 To $theWinlist[0][0]
            If $theWinlist[$i][0] <> "" Then
                $iPID2 = WinGetProcess($theWinlist[$i][1])
                If $iPID2 = $aPID Then
                    $hWnd2 = $theWinlist[$i][1]
                    ExitLoop
                EndIf
            EndIf
        Next
    Until $hWnd2 <> 0
    Sleep(1000)

    Send("{ALT}FO")
    WinWaitActive("Open Source File(s)", "", 10)
    Sleep(200)
    ControlClick("Open Source File(s)", "", 1)
    Sleep(200)
    Send("^a{ENTER}")
    Sleep(200)
    Do
        Sleep(200)
        If WinExists("@icon sushi", "is not a supported file") Then
            Sleep(200)
            Send("{ENTER}")
        EndIf
        $treeCtrl = ControlGetHandle($hWnd2, "", "[CLASS:TListView; INSTANCE:1]")
        ControlClick($hWnd2, "", $treeCtrl, "", "", 34, 29)
        $textCtrl = ControlGetHandle($hWnd2, "", "[CLASS:TPanel; INSTANCE:3]")
    Until ControlGetText($hWnd2, "", $textCtrl) <> ""
    Sleep(200)

    While 1
        $textSrch = ControlGetText($hWnd2, "", $textCtrl)
        If $textSrch = $last Then ExitLoop
        If StringInStr($textSrch, "256 x 256") Then
            Send("{ALT}L")
            Sleep(30)
            Send("D")
            Sleep(30)
            Send("D{ENTER}")
        Else
            Send("{DOWN}")
        EndIf
        $last = $textSrch
    WEnd
    Sleep(200)
    Send("{ALT}LA")
    Sleep(200)
    Send("{ALT}TG")
    WinWaitActive("Browse for Folder", "", 10)
    $hnd = WinGetHandle("Browse for Folder")
    ControlClick($hnd, "", 14145)
    Sleep(100)
    Send("ico2dlltemp")
    Sleep(100)
    Send("{RIGHT}")
    Sleep(100)
    Send("{RIGHT}")
    Sleep(100)
    Send("{ENTER}")
    WinClose($hWnd2)
    WinWaitClose($hWnd2)
EndFunc   ;==>Rmv256

Func GenDll()
    If _GenerateRC() Then
        $SName = $Dll_File_Name
        FileInstall("./Tools/cvtres.exe", $TmpDir & "\", 1)
        FileInstall("./Tools/link.exe", $TmpDir & "\", 1)
        FileInstall("./Tools/mspdb50.dll", $TmpDir & "\", 1)
        FileInstall("./Tools/RC.exe", $TmpDir & "\", 1)
        FileInstall("./Tools/RCdll.dll", $TmpDir & "\", 1)

        $i = 1
        $IdxCount = $vdata2[0] - 2
        For $i = 0 To $IdxCount
            $RC_Res_FilePath = $vdata2[$i + 1]
            FileCopy($RC_Res_FilePath, $TmpDir & "\", 9)
        Next

        RunWait(@ComSpec & ' /c ' & 'rc /r ' & $SName & '.rc', $TmpDir, @SW_HIDE)
        RunWait(@ComSpec & ' /c ' & 'link /nodefaultlib /dll /machine:ix86 /noentry /out:' & _
                $SName & '.dll ' & $SName & '.res', $TmpDir, @SW_HIDE)

        If FileExists($TmpDir & "\" & $SName & ".dll") Then
            FileCopy($TmpDir & "\" & $SName & ".dll", "C:\" & $SName & "-" & $rnd & ".dll", 1)
            MsgBox(0, "Success", "File created successfuly at:" & @CRLF & "C:\" & $SName & "-" & $rnd & ".dll")
            DirRemove($tmp)
            DirRemove($TmpDir)
            Exit
        Else
            MsgBox(16 + 8192, $lang[51], $lang[52] & @TAB) ; Error ; Error Creating Dll File
            Exit
        EndIf
        ;ShellExecute($TmpDir)
    EndIf
EndFunc   ;==>GenDll

Func CopyTemp()
    $i = 1
    For $i = 1 To $iData[0] - 1
        $iData2 = StringReplace($iData[$i], @CR, "")
        FileCopy($iData2, $tmp & $i & ".ico", 9)
        If @error Then
            MsgBox(0, "Failed", "Unknown error. Sorry.")
            Exit
        EndIf

    Next
EndFunc   ;==>CopyTemp

Func _CleanInput()
    _GUICtrlListView_SetItemSelected($Res_List, $ListViewIndexSel, False)
    $ListViewIndexSel = ""
    GUICtrlSetData($Res_Name, "")
    GUICtrlSetData($Res_Type, "ICON")
    GUICtrlSetData($Res_Path, "")
EndFunc   ;==>_CleanInput

Func _PathLen($PathIn)
    If StringLen($PathIn) > $StrLenPath Then
        $StrLenPath = StringLen($PathIn) + 10
        GUICtrlSendMsg($Res_List, $LVM_SETCOLUMNWIDTH, 2, $StrLenPath * 5)
    EndIf
EndFunc   ;==>_PathLen

Func _UpdateVerNum()

    GUICtrlSetData($Dll_Ver1, StringFormat("%002s", GUICtrlRead($Dll_Ver1)))
    GUICtrlSetData($Dll_Ver2, StringFormat("%002s", GUICtrlRead($Dll_Ver2)))
    GUICtrlSetData($Dll_Ver3, StringFormat("%004s", GUICtrlRead($Dll_Ver3)))
    GUICtrlSetData($Dll_Ver4, StringFormat("%004s", GUICtrlRead($Dll_Ver4)))

    GUICtrlSetData($Dll_PVer1, StringFormat("%002s", GUICtrlRead($Dll_Ver1)) & "," & _
            StringFormat("%002s", GUICtrlRead($Dll_Ver2)) & "," & _
            StringFormat("%004s", GUICtrlRead($Dll_Ver3)) & "," & _
            StringFormat("%004s", GUICtrlRead($Dll_Ver4)))
EndFunc   ;==>_UpdateVerNum

Func _GenerateRC()
    $vdata2 = _FileListToArray($tmprmv)
    $i = 1
    For $i = 1 To $vdata2[0]
        FileCopy($tmprmv & $vdata2[$i], $TmpDir & "\" & $i & ".ico", 9)
    Next
    $vdata2 = _FileListToArray($tmprmv)
    $IdxCount = $vdata2[0]
    $i = 1
    If $IdxCount > 0 Then
        $RCFile = $TmpDir & "\" & $Dll_File_Name & ".rc"
        $hRCOut = FileOpen($RCFile, 1)
        If $hRCOut = -1 Then Return 0
        $RC_Res_Type = "ICON"
        For $i = 1 To $IdxCount
            FileCopy($tmprmv & $vdata2[$i], $TmpDir & "\" & $i & ".ico", 9)
            $RC_Res_Name = $i
            $RC_Res_FilePath = $TmpDir & "\" & $i & ".ico"
            _PathSplit($RC_Res_FilePath, $szDrive, $szDir, $szFName, $szExt)
            $RC_Res_File = $szFName & $szExt
            FileWriteLine($RCFile, $RC_Res_Name & @TAB & $RC_Res_Type & @TAB & '"' & $RC_Res_File & '"')
        Next

        FileWriteLine($RCFile, @CRLF & '1 VERSIONINFO' & @CRLF & _
                'FILEVERSION ' & $Dll_PVer1 & @CRLF & _
                'PRODUCTVERSION ' & $Dll_PVer1 & @CRLF & _
                'FILEOS ' & $Dll_OS & @CRLF & _
                'FILETYPE ' & $Dll_File_Type & @CRLF & _
                '{' & @CRLF & 'BLOCK "StringFileInfo"' & @CRLF & '{' & @CRLF & _
                @TAB & 'BLOCK "' & $Bloc & '"' & @CRLF & @TAB & '{' & @CRLF & _
                @TAB & @TAB & 'VALUE "CompanyName", "' & $Dll_Compagny & '"' & @CRLF & _
                @TAB & @TAB & 'VALUE "FileDescription", "' & $Dll_File_Desc & '"' & @CRLF & _
                @TAB & @TAB & 'VALUE "FileVersion", "' & $Dll_PVer1 & '"' & @CRLF & _
                @TAB & @TAB & 'VALUE "InternalName", "' & $Dll_File_Name & '.dll"' & @CRLF & _
                @TAB & @TAB & 'VALUE "LegalCopyright", "' & $Dll_Copyright & '"' & @CRLF & _
                @TAB & @TAB & 'VALUE "OriginalFilename", "' & $Dll_File_Name & '.dll"' & @CRLF & _
                @TAB & @TAB & 'VALUE "ProductName", "' & $Dll_Prod_Name & '"' & @CRLF & _
                @TAB & @TAB & 'VALUE "ProductVersion", "' & $Dll_PVer1 & " " & $Dll_PVer2 & '"' & @CRLF & _
                @TAB & @TAB & 'VALUE "Comments", ""' & @CRLF & _
                @TAB & '}' & @CRLF & '}' & @CRLF & @CRLF & 'BLOCK "VarFileInfo"' & @CRLF & '{' & @CRLF & _
                @TAB & 'VALUE "Translation", ' & $LangHex & @CRLF & '}' & @CRLF & '}')

        FileClose($hRCOut)
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>_GenerateRC

Func On_WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam)
    ; Credit to ProgAndy for DLL calls
    #forceref $hWnd, $iMsg, $lParam
    Local $iSize, $pFileName
    ; Get number of files dropped
    Local $aRet = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 0)
    ; Reset array to correct size
    Global $aDrop_List[$aRet[0] + 1] = [$aRet[0]]
    ; And add item names
    For $i = 0 To $aRet[0] - 1
        $aRet = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $iSize = $aRet[0] + 1
        $pFileName = DllStructCreate("wchar[" & $iSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $iSize)
        $aDrop_List[$i + 1] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
    ; Send the count to trigger the drop function in the main loop
    GUICtrlSendToDummy($dBox, $aDrop_List[0])

EndFunc   ;==>On_WM_DROPFILES

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    ;#forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $Res_List
    If Not IsHWnd($Res_List) Then $hWndListView = GUICtrlGetHandle($Res_List)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $ListViewIndexSel = DllStructGetData($tInfo, "Index")
                    GUICtrlSetData($Res_Name, _GUICtrlListView_GetItemText($hWndListView, $ListViewIndexSel, 0))
                    GUICtrlSetData($Res_Type, _GUICtrlListView_GetItemText($hWndListView, $ListViewIndexSel, 1))
                    GUICtrlSetData($Res_Path, _GUICtrlListView_GetItemText($hWndListView, $ListViewIndexSel, 2))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetDllData()
    Switch GUICtrlRead($Dll_Lang)
        Case 'French' Or 'Francais'
            $Bloc = '040C04B0'
            $LangHex = '0x040C 0x04B0'
        Case Else ; 'English' Or 'Anglais'
            $Bloc = '040904B0'
            $LangHex = '0x0409 0x04B0'
    EndSwitch
    $Dll_File_Name = StringReplace(GUICtrlRead($Dll_File_Name), " ", "_")
    $Dll_PVer1 = GUICtrlRead($Dll_PVer1)
    $Dll_PVer2 = GUICtrlRead($Dll_PVer2)
    $Dll_OS = GUICtrlRead($Dll_OS)
    $Dll_File_Type = GUICtrlRead($Dll_File_Type)
    $Dll_Compagny = GUICtrlRead($Dll_Compagny)
    $Dll_File_Desc = GUICtrlRead($Dll_File_Desc)
    $Dll_Copyright = GUICtrlRead($Dll_Copyright)
    $Dll_Prod_Name = GUICtrlRead($Dll_Prod_Name)

EndFunc   ;==>SetDllData



; Function to select language.
Func _SelectLanguage()
    If StringInStr("040c,080c,0c0c,100c,140c,180c", @OSLang) Then
        RDG_FR() ; French Language
    Else
        RDG_EN() ; English Language
    EndIf
    $Lang = StringSplit($Lang, $SP, 1)
EndFunc

; English Language.
Func RDG_EN()
    $Lang = "Resource DLL Generator" & $SP
    $Lang &= "Resource Name" & $SP
    $Lang &= "Type Name Without Space (Max len 10)" & $SP
    $Lang &= "Resource Type" & $SP
    $Lang &= "Choose Resource Type" & $SP
    $Lang &= "Resource Path" & $SP
    $Lang &= "Select File First" & $SP
    $Lang &= "Path Of The Resource File" & $SP
    $Lang &= "Select Path Of The Resource File First" & $SP
    $Lang &= "Delete Resource" & $SP
    $Lang &= "Delete Selected Resource" & $SP
    $Lang &= "Add Resource" & $SP
    $Lang &= "Add or Update Resource" & $SP
    $Lang &= " Name | Type | Path " & $SP
    $Lang &= "Clic Twice To Edit An Item" & $SP
    $Lang &= "Exit" & $SP
    $Lang &= "Exit Program" & $SP
    $Lang &= "Dll Informations" & $SP
    $Lang &= "Chose Dll Informations" & $SP
    $Lang &= "Generate Dll" & $SP
    $Lang &= "Generate The Dll" & $SP
    $Lang &= "DLL Info" & $SP
    $Lang &= "DLL Informations" & $SP
    $Lang &= "Dll Filename" & $SP
    $Lang &= "MyDll" & $SP
    $Lang &= "File Version" & $SP
    $Lang &= "Product Version" & $SP
    $Lang &= "Product Name" & $SP
    $Lang &= "Name_Of_Your_Product" & $SP
    $Lang &= "Compagny Name" & $SP
    $Lang &= "Type_Your_Compagny" & $SP
    $Lang &= "Legal Copyright" & $SP
    $Lang &= "Copyright_(C)_2007-2008" & $SP
    $Lang &= "File Description" & $SP
    $Lang &= "Type_Your_Description" & $SP
    $Lang &= "Language" & $SP
    $Lang &= "English|French" & $SP
    $Lang &= "English" & $SP
    $Lang &= "File OS" & $SP
    $Lang &= "0x40004" & $SP
    $Lang &= "0x40004" & $SP
    $Lang &= "File Type" & $SP
    $Lang &= "0x2" & $SP
    $Lang &= "0x2" & $SP
    $Lang &= "OK" & $SP
    $Lang &= "Select file to add In DLL" & $SP
    $Lang &= "All" & $SP
    $Lang &= "Select The Destination Of Dll File" & $SP
    $Lang &= "Succes" & $SP
    $Lang &= "Dll successfully saved on" & $SP
    $Lang &= "Error" & $SP
    $Lang &= "Error Creating Dll File" & $SP
    $Lang &= "Dll File Name" & $SP
    $Lang &= "Please, Enter The Name Of Your Dll"
EndFunc

; French Language.
Func RDG_FR()
    $Lang = "Ressource DLL Generator" & $SP
    $Lang &= "Nom de la ressource" & $SP
    $Lang &= "Tapez le nom sans espace (Max 10 caractères)" & $SP
    $Lang &= "Type de la ressource" & $SP
    $Lang &= "Choisissez un type de ressource" & $SP
    $Lang &= "Chemin de la ressource" & $SP
    $Lang &= "Choisir d'abord le fichier de ressource" & $SP
    $Lang &= "Chemin du fichier de ressource" & $SP
    $Lang &= "Sélectionnez le fichier de ressource" & $SP
    $Lang &= "Supprime ressource" & $SP
    $Lang &= "Supprime la ressource sélectionnée." & $SP
    $Lang &= "Ajoute ressource" & $SP
    $Lang &= "Ajoute ou met à jour la ressource." & $SP
    $Lang &= " Nom | Type | Chemin " & $SP
    $Lang &= "Cliquez deux fois pour éditer une ressource." & $SP
    $Lang &= "Sortie" & $SP
    $Lang &= "Sortie du programme." & $SP
    $Lang &= "Informations Dll" & $SP
    $Lang &= "Règlez les information de la Dll." & $SP
    $Lang &= "Générer la Dll" & $SP
    $Lang &= "Générez la Dll" & $SP
    $Lang &= "Info DLL" & $SP
    $Lang &= "Informations DLL" & $SP
    $Lang &= "Nom de la Dll" & $SP
    $Lang &= "MaDll" & $SP
    $Lang &= "Version du fichier" & $SP
    $Lang &= "Version du produit" & $SP
    $Lang &= "Nom du produit" & $SP
    $Lang &= "Nom_de_votre_produit" & $SP
    $Lang &= "Nom de la société" & $SP
    $Lang &= "Nom_de_votre_société" & $SP
    $Lang &= "Copyright légale" & $SP
    $Lang &= "Copyright_(C)_2007-2008" & $SP
    $Lang &= "Description du fichier" & $SP
    $Lang &= "Entrez_votre_description" & $SP
    $Lang &= "Langue" & $SP
    $Lang &= "Anglais|Français" & $SP
    $Lang &= "Français" & $SP
    $Lang &= "Système de fichiers" & $SP
    $Lang &= "0x40004" & $SP
    $Lang &= "0x40004" & $SP
    $Lang &= "Type de fichiers" & $SP
    $Lang &= "0x2" & $SP
    $Lang &= "0x2" & $SP
    $Lang &= "OK" & $SP
    $Lang &= "Sélectionnez le fichier à ajouter à la DLL" & $SP
    $Lang &= "Tout Fichier" & $SP
    $Lang &= "Sélectionnez la destination de la Dll" & $SP
    $Lang &= "Succés" & $SP
    $Lang &= "Dll sauvegardée avec succés sur" & $SP
    $Lang &= "Erreur" & $SP
    $Lang &= "Erreur lors de la création de la Dll" & $SP
    $Lang &= "Nom du fichier Dll" & $SP
    $Lang &= "Veuillez entrer le nom de la Dll"
EndFunc

 

ico2dll.Exe

Edited by Inpho
Link to comment
Share on other sites

Updated; uses WinWaitActive and less sleep, should be fine no matter how slow a PC is. I tried with 300 icons, runs fine.

icon sushi doesn't support 512 x 512 icons so if your icon contains >= 512 x 512 elements then it will be ignored.

Link to comment
Share on other sites

This takes as many .ico files as you give it and compiles them into a resource-only .dll. Firstly it removes all 256 x 256 elements from each individual .ico file using icon sushi; then adds them into RDG; then finally compiles the .dll

There are many guides on how to do this but they all assume various levels of knowledge. This script allows someone with minimal knowledge to compile a resource-only .dll.

Link to comment
Share on other sites

  • 6 months later...

@Inpho this is really cool.  I do this manually. :) 

Question - in future  sizes >= 256 x 256 will certainly be supported.  Why not future proof and simply allow the bigger size now, even if they can't be used?  As the bigger sizes become supported, it will not be necessary to update the resource dll...

 

And, I am now on Win10. :( 

It tried to make the DLL, then displayed... new file created at "C:\mynewdll2-4842.dll" - of course Win10 did not allow the File Write in the C: root.  Any ideas?

Edited by Skysnake
more...

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

  • 3 weeks later...
On 10/05/2016 at 3:12 PM, Skysnake said:

@Inpho this is really cool.  I do this manually. :) 

Question - in future  sizes >= 256 x 256 will certainly be supported.  Why not future proof and simply allow the bigger size now, even if they can't be used?  As the bigger sizes become supported, it will not be necessary to update the resource dll...

It tried to make the DLL, then displayed... new file created at "C:\mynewdll2-4842.dll" - of course Win10 did not allow the File Write in the C: root.  Any ideas?

The 256 x 256 is a restriction imposed by the RC.exe from Microsoft. I couldn't get around it. I tried using trancexx's ResourcesViewerAndCompiler but it was extremely slow to batch-create a 250+ icon .dll; although it did get around the 256 x 256 restriction 'cause she's just a genius.

Either give yourself admin rights or change the line in GenDll() from:

FileCopy($TmpDir & "\" & $SName & ".dll", "C:\" & $SName & "-" & $rnd & ".dll", 1)

to

FileCopy($TmpDir & "\" & $SName & ".dll", @MyDocumentsDir & "\" & $SName & "-" & $rnd & ".dll", 1)

Or something. Ultimately, there is a better way to do this, but I've given up as this fits my needs. I only need 48 x 48 icons across the board.

Edited by Inpho
Link to comment
Share on other sites

  • 1 year later...

Some comments.

I am struggling with this.

I am on Win10.  It seems that the EXE contains all the includes, but these are not available as a separate zip.

Also, it looks like the AU3 is older than the EXE, or at least not the same version?

In the first post there are TWO downloads for the EXE?  Could you please be so kind as to make one download for the EXE and another for the au3 and all includes & FileInstalls? Problem is that your write to "c:\[root] " regardless and Windows 10 doesnt like that.  Also, personally I would prefer if it just goes into the @ScriptDir instead of the c: root.

When I run the EXE, it asks for the icon, I provide one, it jiggles and bobs and then produces a MSgBox stating "created" but... does nothing... :(

I changed this:

$tmp = @ScriptDir & "\newicondll\" ;"C:\ico2dlltemp\"
ConsoleWrite("$tmp "&$tmp&@CRLF)
$tmprmv = @ScriptDir & "\newicondll\rmv\"  ; "C:\ico2dlltemp\rmv\"
ConsoleWrite("$tmprmv "&$tmprmv&@CRLF)

.

;    IniWrite(@ScriptDir & "\aicon.ini", "Option", "InitialDir", "C:\ico2dlltemp")
 IniWrite(@ScriptDir & "\aicon.ini", "Option", "InitialDir", $tmp   )

.

If FileExists($TmpDir & "\" & $SName & ".dll") Then
;            FileCopy($TmpDir & "\" & $SName & ".dll", "C:\" & $SName & "-" & $rnd & ".dll", 1)
Local $outTarget = @ScriptDir & $SName & "-" & $rnd & ".dll"
            FileCopy($TmpDir & "\" & $SName & ".dll", $outTarget, 1)
            MsgBox(0, "Success", "File created successfuly at:" & @CRLF & $outTarget)
            DirRemove($tmp)
            DirRemove($TmpDir)
            Exit
        Else

No result... 

I ran the EXE to get the installs, then the AU3 as from above. I insert a single icon. It just dies...

Console reports this

"C:\AutoIt\makeDLL\ico2dllx.au3" (364) : ==> Subscript used on non-accessible variable.:
For $i = 1 To $vdata2[0]
For $i = 1 To $vdata2^ ERROR
->09:37:30 AutoIt3.exe ended.rc:1
+>09:37:30 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 22.47

Are there more hardcoded c:\[root] lines?

Thanks

Skysnake

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

@Skysnake I must admit, when I did this I was a complete nab.

Okay, I still am.

I played with trancexx's Resource Viewer and Compiler but I don't understand all of the code so my attempt to automate the compiling of 300+ icons was still not optimal. It's fast for the first 50 icons, then slows to a crawl. IIRC it was a recursive function that defeated me.

Give this a go, it also has the added bonus of not rejecting .ico's with layers 256 x 256 or larger.

ResourcesViewerAndCompilerModified.au3

Action -> Initialise compiler

Action -> Generate inital dll

Drag-and-drop icons in (only one drag-and-drop operation as its late and remember- im a nab)

File -> Save as...

Edited by Inpho
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 years later...
On 5/29/2016 at 8:34 AM, Inpho said:

Either give yourself admin rights or change the line in GenDll() from:

FileCopy($TmpDir & "\" & $SName & ".dll", "C:\" & $SName & "-" & $rnd & ".dll", 1)

to

FileCopy($TmpDir & "\" & $SName & ".dll", @MyDocumentsDir & "\" & $SName & "-" & $rnd & ".dll", 1)

 

 

I registered here because need some help if you don't mind for further support.  first of, great program man really helps to reduce ton of small files into a single dll this is what I am looking for. however few issue.

you mentioned above change GenDll() line is in the ico2dll.Exe, RC.exe or which file?

finally, when I run ico2dll.exe it starts with a window ask me to enter the .dll name and company info etc. how can I make it so that it doesn't force me to enter all the other info? I only wish to enter the name of .dll I'm trying to save, or at least have a way to pre populate these info is that possible?

 

thank you for your time!

Link to comment
Share on other sites

  • 1 year later...
  • Moderators

PwrSrg,

If you could provide some more information about just where it "breaks" we might be able to help. For example, show us the SciTE output pane with the errors found when you try to run the script.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 2 years later...

The attached file contains a trojan do not run it as its probably a password stealer.
I scanned it with malwarebytes but was first detected by windows defender

image.png.f62cadb705ceea74344b781b37f98e8a.png

Edited by Melba23
Fixed SHOUTING font
Link to comment
Share on other sites

  • Moderators

trojan-warner,

The file is highly unlikely to be a trojan - please read this thread.

And we all know about ResHacker.

M23

P.S. Please use standard fonts in future.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

49 minutes ago, Melba23 said:

trojan-warner,

The file is highly unlikely to be a trojan - please read this thread.

And we all know about ResHacker.

M23

P.S. Please use standard fonts in future. 

(P.S. Please use standard fonts in future.) Ok

hmm ok it still didn't work on windows 10 but I think that is stated somewhere else already.

So the antivirus just flagged it because it is made by auto it script.

which I dont get why the antiviruses even do because its like marking python exes as a trojan or java.

They should change it to a warning in stead of a flat out marking it like its malware or trojan.

Like "This scripting language is not well known so there is a possibility it could be malware do you wane remove?"

With a link to FAQ about why can't detect if is malware.

Also sorry for the name can't seem to change it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...