A customer had trouble getting an icon to display for a registered file type. In my resource file, I specify the icon like this: 101 ICON awesome.ico And when I register my file type, I set it like this: [HKEY_CLASSES_ROOT\.xyz\DefaultIcon]
@="C:\path\to\awesome.exe,101" However, when I view an .xyz file, my awesome icon doesn't appear. On the other hand, if I change the 101 to a 0, then it works. Why? Isn't the number in the resource file the resource ID? Why yes, in fact, the number in the resource file is indeed the resource ID. But the number after the comma in the DefaultIcon isn't.The format of shell icon locations (used most visibly by DefaultIcon, but also used in other places) is «file»,«index», where the index is a zero-based index of the icon in your resources. In other words, an index of zero means "Give me the first icon in the file." The resource compiler sorts icons numerically by resource ID, so the first icon in the file is the icon with the numerically lowest resource ID. In the above example, apparently there are no icons with resource IDs less than 101; that would explain why asking for icon index zero results in the awesome icon. The function behind all this icon hunting is ExtractIcon. The icon location string is split up at the comma into a path and an integer, and that path and integer are passed to the ExtractIcon function. Since the ExtractIcon function interprets the integer as the icon index, that's what the integer in your icon location string means. Read more: The old new thing
@="C:\path\to\awesome.exe,101" However, when I view an .xyz file, my awesome icon doesn't appear. On the other hand, if I change the 101 to a 0, then it works. Why? Isn't the number in the resource file the resource ID? Why yes, in fact, the number in the resource file is indeed the resource ID. But the number after the comma in the DefaultIcon isn't.The format of shell icon locations (used most visibly by DefaultIcon, but also used in other places) is «file»,«index», where the index is a zero-based index of the icon in your resources. In other words, an index of zero means "Give me the first icon in the file." The resource compiler sorts icons numerically by resource ID, so the first icon in the file is the icon with the numerically lowest resource ID. In the above example, apparently there are no icons with resource IDs less than 101; that would explain why asking for icon index zero results in the awesome icon. The function behind all this icon hunting is ExtractIcon. The icon location string is split up at the comma into a path and an integer, and that path and integer are passed to the ExtractIcon function. Since the ExtractIcon function interprets the integer as the icon index, that's what the integer in your icon location string means. Read more: The old new thing
0 comments:
Post a Comment