Functions for Resource-Only DLL

Post your working scripts, libraries and tools
User avatar
SKAN
Posts: 310
Joined: 29 Sep 2013, 16:58

DllPackIcons()

20 Sep 2017, 15:13

DllPackIcons( Folder, DLL, nICON, nGROUPICON )

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus





Example 1:
Icons will be added in the order populated by File system.
It NTFS, The .ICO files will be in alphabetical order and in FAT32 the list will be in no particular order.

Code: [Select all] [Download] GeSHi © Codebox Plus

DLL := DllCreateEmpty( A_ScriptDir "\Icons.dll" )
DllPackIcons( "D:\MyIcons\", DLL )


Example 2:
Icons will be added exactly as it appears in the "files" list.

Code: [Select all] [Download] GeSHi © Codebox Plus

DLL := DllCreateEmpty( A_ScriptDir "\Icons.dll" )
Files := "
(
D:\MyIcons\Icon3.ico
D:\MyIcons\Icon1.ico
D:\MyIcons\Icon2.ico
)"

DllPackIcons( Files, DLL )
User avatar
hoppfrosch
Posts: 285
Joined: 07 Oct 2013, 04:05
GitHub: hoppfrosch
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: Functions for Resource-Only DLL

21 Sep 2017, 04:39

Thanks SKAN - my tests work without a flaw yet...! :dance:

What would be nice (but I don't know whether it's possible at all): name the icons within the DLL according their filenames (without extension of course) - instead of using an anonymous number ....
just me
Posts: 4685
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Functions for Resource-Only DLL

21 Sep 2017, 05:55

It's possible for icon groups, but afaik you cannot extract an icon by name using the built-in AHK commands/functions.
Remaining with AHK 1.1.25.02 until v2 will become beta.
User avatar
SKAN
Posts: 310
Joined: 29 Sep 2013, 16:58

Re: Functions for Resource-Only DLL

21 Sep 2017, 12:10

hoppfrosch wrote:Thanks SKAN - my tests work without a flaw yet...! :dance:


Glad to know.
I forgot to mention:
DllPackIcons() doesn't trust file extensions. Each and every file is opened and confirmed to have an ICONDIR in header.
This is because .BMP files can be renamed to .ICO and Windows will accept/load it as icon.
So, If you have a .ICO that is not being added, make sure it isn't a BMP file.

What would be nice (but I don't know whether it's possible at all): name the icons within the DLL according their filenames (without extension of course)


I had thought of it. As just me said, the names aren't very useful as AutoHotkey loads icon by its position (1 based index) rather than its ID.
Also implementing it would be hard. For example, if icon filename is either "HOPP.ico" or "123.ico", I know the first one should be saved as string and the latter as a number. What if you order/name your icons like "0001.ico", "0002.ico... "1234.ico".
Then I will have to accept a filelist as a CSV with two parameters.

hoppfrosch wrote:instead of using an anonymous number ....

The numbers matches actual index AutoHotkey uses. If you look at the code, you may see that the functions doesn't allow using 0 as the starting number, specifically for this reason (and also: 0 should be stored as a string)

:)
User avatar
hoppfrosch
Posts: 285
Joined: 07 Oct 2013, 04:05
GitHub: hoppfrosch
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: Functions for Resource-Only DLL

25 Sep 2017, 00:01

Naming is not really a problem - I just had my icons clearly named and was "disappointed" at the first look, after seeing my names got lost within the dll. I'm fine with this.

Thanks SKAN for your great work. :clap:
gwarble
Posts: 220
Joined: 30 Sep 2013, 15:01

Re: Functions for Resource-Only DLL

25 Sep 2017, 17:47

the names aren't very useful as AutoHotkey loads icon by its position (1 based index) rather than its ID.


if you wanted to use named icon group resources you can access them by the native winapi calls, LoadIcon or LoadImage

Probably more trouble than its worth in most cases, but if you had lots of icons to deal with it might be beneficial in some cases
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 13 guests