Results 1 to 4 of 4

Thread: Retrieving the Default Icon from the Registry

  1. #1

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185

    Question

    I'm having a problem retrieving the default icon picture on a few file types.

    Usually you lookup the file extension (e.g. HKEY_CLASSES_ROOT\.doc) and read the default value.
    You then find the key under the HKEY_CLASSES_ROOT with the same value (e.g. HKEY_CLASSES_ROOT\Word.Document.8), and under that key there should be a DefaultIcon key. The default value of the DefaultIcon key should tell you the file where the icon lives and which icon to use (e.g. C:\Program Files\Microsoft Office\Office\Winword.exe,1).

    The problem I'm having is that some file types have a %1 stored in the DefaultIcon key. The HKEY_CLASSES_ROOTS\exefile\DefaultIcon and HKEY_CLASSES_ROOTS\visio.drawing.6\DefaultIcon file types are examples of this.

    My question is how do you work out the Default Icon, when the DefaultIcon registry setting is set to %1?

    Thanks in advanced.
    Last edited by VB6Coder; Apr 17th, 2001 at 06:50 AM.

  2. #2

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185
    I can understand using the file icon in the file for .exe files and .ico files, but I can't understand why Visio.Drawing.8 DefaultIcon default value is set to %1. A .vsd file doesn't have an icon stored in it.

    Also if you create a shortcut to a .vsd file, go into properties and click on the Change Icon button, it shows that the selected icon is the 2nd icon in the C:\WINDOWS\SYSTEM\VISSHE32.DLL file.

    How does it know this?

  3. #3
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Each document type has an associated application (.exe) .

    In each application there may be icon resources embedded into it. These are numbered starting at 0.

    This means that if the return from the "associated icon" section of the registry is not a filename then you need to find th eassociated application (.exe) file and then do an ExtractAssociatedIcon() call to get the relevant icon.

    This association is the same mechanism as is used to launch an application from it's data file in Explorer.

    HTH,
    D.

  4. #4

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185

    Smile

    How do I get a handle to the 16x16 icon using the ExtractAssociatedIcon API function?

    The ExtractIconEx API function has parameters which are used to return handles to the 32x32 icon and the 16x16 icon.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width