Change document icon after first launch in Windows

I have an application that gets installed with the Wise installer (EDIT: Wise creates a Setup.exe file, not an MSI). After installation, an icon is installed for a specific file type:

HKEY_CLASSES_ROOT\.auz\DefaultIcon = C:\Path\To\App\some_icon.ico,0

      

However, immediately after installation, Explorer selects this icon using the generic "white sheet + app icon" icon, which is different (and not provided by me).

On first launch, the application itself registers icons and other file associations so that the latest version of the launch "owns" these documents. At this point, Explorer changes the icon for that file type and displays the correct one, but when I look at the registry, the DefaultIcon value matches exactly .

This is what I have tried so far

  • Remove all entries from the registry and write them.
  • Once installed, "touching" the DefaultIcon value and then running a small little program that only calls SHChangeNotify (SHCNE_ASSOCCHANGED) (my program does this after updating the file associations in the registry).
  • After installing, destroying and restarting the explorer.
  • After installation, use TweakUI to "restore" the icons on the desktop.

None of these works. The only way to get the right icon is to let the program itself install it. I cannot find any changes in the registry. I pull back my hair.

What I would like to avoid

  • Testing with other installation software.
  • Too many changes in the installation script (I don't have the Wise One as the installer is built on a different machine on demand).
  • Insert icons into executable file.

Any suggestions on how to get Explorer to display the correct icon after installation?

+1


source to share


2 answers


Here's the solution.

Each file type (say ".auz" in this case) has been registered:

  • A DefaultIcon

    with the path to the icon resource and
  • A value for a value HKEY_CLASSES_ROOT\.auz\(default)

    giving a description of the file type, eg. "Document Foobar".

In addition to this, an entry was introduced for the document type "Foobar Document", or more specifically, a key to open such documents from the shell:

HKEY_CLASSES_ROOT\Foobar Document\Shell\command\open\(default) = C:\Path\To\App.exe "%1"

      



This key appears to override the value recorded for the specific file extension . Since the icons are external to the .exe file, Windows Explorer then used the first application icon to create an icon for all files of type "Foobar Document" (the "white sheet + application icon" icon I mentioned).

Now I was wrong about the application itself changing the value

HKEY_CLASSES_ROOT\.auz\(default)

      

to a slightly different value on startup, say "Foobar 1.2 Document" (not dry problem). Thus, the link to the "Foobar Document" was lost, and the .auz files got their icons after the first launch.

So, I fixed it all by simply removing the key HKEY_CLASSES_ROOT\Foobar Document

altogether, and voilΓ !

+1


source


Several things come to mind:

  • Why do you have a "0" after the icon in the registry? This would limit the displayed icon to one icon. Better would be to have an icon file that contains multiple icons (same UI icon but different sizes / color depths). Explorer has different kinds of icons! Try removing ', 0' if you only have one icon in your icon file.
  • It is possible that the registry is written last in the installer after Explorer has received the update notification.
  • make sure the registry entry is written after the icon file is stored on disk
  • you must use your own Wise config to register the file type. Not sure, but I think File Explorer won't accept any changes until the entire msi installation is complete, so calling SHChangeNotify () manually won't help. Msi has its own table for this, which Wise will add if you use the correct configuration.

For Wise, follow these steps (instead of creating the registry keys yourself):



  • In the Feature Details page group, select the File Links page.
  • Select Core from the Current Feature drop-down list.
  • Click "Add" on the right side of the window and select "New". The File Association Information dialog box appears.
  • Click the Details tab.
  • Go to the QuickFacts directory, select the QckFacts.exe file and click "OK".
  • In Extension enter: qft
  • Leave the default values ​​for the rest of the fields and click OK. The .QFT extension is added to the installation. When an end user double-clicks a file with that extension on the destination computer, the QuickFacts application launches.
  • Save installation

[Edit] You can also skip the required registry entries (the icon may not be enough to display the shell):

HKEY_CLASSES_ROOT\.auz\(default) = auzfile
HKEY_CLASSES_ROOT\.auz\shell\open\command = C:\Path\To\App.exe

      

+1


source







All Articles