Winodws uses a special browser to show all icons contained in a file and offers the end user the possibility to choose an icon from it. You can add this functionallity to your applications through an undocumented API function, SHChangeIconDialog. Its Declare is:
Declare Function SHChangeIconDialog Lib "shell32" Alias "#62" (ByVal hOwner As _ Long, ByVal szFilename As String, ByVal Reserved As Long, _ lpIconIndex As Long) As Long
The first argument is the dialog owner: you can specify 0 for desktop, in order to make it a top-level window. The second argument is the file that is initially displayed and opened. I didn’t find a use for the third argument, so you should consider it as “reserved” and always pass zero to it. Finally, the last argument is the index of the icon that will be selected when the dialog is opened.
The function returns 0 if the dialog is cancelled and non-zero in all other cases. When the function returns it stores the index of the selected incon in the last argument: you can use this index to extract the icon by using ExtractIconEx or whatelse you want. Here’s a routine tha encapsulates this functionality:
' Display an icon browser and return the index of the selected icon,' or -1 if the user didn't select any iconPrivate Function DoIconDialog (ByVal sFile as String, Byval nIndex as Long) As _ Long If SHChangeIconDialog(Me.hWnd, StrConv(sFile, vbUnicode), 0, nIndex) Then DoIconDialog = nIndex Else DoIconDialog = -1 End IfEnd Function