Jump to content
c.haslam

[Solved] How to get resource name for an icon given its number

Recommended Posts

Because I find Corel's DialogEditor to be inferior to what can be done in Koda, I have written a macro that generates PerfectScript dialog code from Koda.

Koda's Picture Editor allows me to choose a .dll or .exe containing icons. I can them choose an icon number.

My problem is with Icon: PerfectScript's DialogAddIcon() requires an icon name rather than an icon number.

My solution is to have the macro run an AutoIt script: an excerpt:

Local $a10Data = _WinAPI_EnumResourceNames($path, $RT_GROUP_ICON)
$iconName = $a10Data[$iconNumber]

$a10Data is a 1-d array.

This works where icon numbers are strictly sequential, but not if they aren't. An example: Koda tells me that wmploc.dll has icon numbers 0 to 156, then 158. If the icon number is <= 156, the correct name is retrieved, but if the icon number is 157, the name of 158 is retrieved.

So I need to get an array of icon numbers. How can I do this in AutoIt?

 

Edited by c.haslam

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Share this post


Link to post
Share on other sites

Use negative number for ordinal and positive number for name ?

Or use _ArraySearch () ? 

Not sure what exactly is your problem 

Share this post


Link to post
Share on other sites

An example of what does work:

Local $a10Data = _WinAPI_EnumResourceNames(@SystemDir & '\wmploc.DLL', $RT_GROUP_ICON)

$a10Data is a 1-dimension array.

ln Koda, I choose icon number 31. Picture Editor numbers are ref. zero. Koda generates

Local $Icon1 = GUICtrlCreateIcon("C:\Windows\System32\wmploc.DLL", -32, 120, 72, 32, 32)

GuiCreateIcon() numbers are ref. 1, so 32 not 31.

$a10Data[32] is 610. icon names are, per Microsoft, strings. PerfectScript's DialogAddIcon() argument is "#610".

When I look in Picture Editor, I see that there are icons for all numbers from 0 up to and including 32. So the element number in the array is the icon number.

But, looking further in Picture Editor, there is a gap in the numbers: the numbers skip from 156 to 158. So if I wanted icon 158, the icon name (less the #) is in a10Data[157], not in a10Data[158] !

Some time back I spent a chunk of time figuring out the difference between icon numbers and icon names. One thing I learnt is that some icon names are alphabetic!


Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Share this post


Link to post
Share on other sites

I have found the solution to my problem.

The array returned by _WinAPI_EnumResourceNames($path, $RT_GROUP_ICON)  has an element for the complete range of icon numbers, even if Picture Editor shows that there is no icon for a particular icon number. Element numbers are icon numbers.

For example, in the case of wmploc.dll, there are elements containing icon names for icon 156, 157 and 158 even though of these icon 157 exists but 156 and 158 do not.

My question now is: how can I detect that an icon does not exist?


Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...