Building an MSI File: Visual Studio and Orca - A First Look at Shortcuts
(Page 3 of 6 )
You installed a shortcut to Notepad in this installation. As you might expect, there is a Shortcut table in the installation package. Figure 2-6 shows the first few columns of the Orca view of the shortcut table and the entry for the shortcut to NOTEPAD.EXE.

Figure 2-6. The Shortcut table
Note that the Component_ column contains the Windows Installer Component that the shortcut belongs to—exactly what you would expect knowing that all installed items belong to a component. There is also a Directory_ column, which effectively names the Program Menu folder and the subfolders that contain the shortcut. There is also an entry in the Target column that contains the name of the only feature in this installation. The fact that this is the name of a feature in the Feature table means that this is an “advertised” shortcut. Although advertised features are associated with the “install on demand” scenario, they have another interesting characteristic, which is that they verify the correctness of their associated installer components. In other words, using the shortcut triggers an automatic repair if the components are “broken.” If you remove the file NOTEPAD.EXE from its installed location on disk and then use the shortcut, you see a Windows Installer dialog that restores the missing file.
Although the name of the shortcut is in the Shortcut table, there is no obvious reference to the actual target file—the installed NOTEPAD.EXE. That’s because the linkage is indirect, through the component name in the Shortcut table. If you look at the Component table in Figure 2-7, the shortcut component is that top one, and that component has a KeyPath entry that is a key into the File table. Referring back to Figure 2-4, you can see that this File table entry is NOTEPAD.EXE. This is a specific case of a general principle in the installer—that a target file is indirectly referenced by naming a component that has a KeyPath entry referring to a File table entry for a file. In other words, the Shortcut table names the component (not the file), and the Component table’s KeyPath entry points to the file. There’s another subtle point to notice here about the Shortcut, which is that a shortcut file is not literally being installed. Although it might have looked as if you were installing an actual file in the IDE—a shortcut—the package contains no such file, just a table entry with the information required to create one.

Figure 2-7. The Component table
If you look at this actual shortcut with Open All Users in Explorer, it looks like Figure 2-8. Compared to noninstaller shortcuts, the Target is grayed out and can’t be altered. This is because this shortcut is encoded with the special behavior that causes Windows to verify the presence of the installer component.

Figure 2-8. A Windows Installer shortcut
This is from The Definitive Guide to Windows Installer, by Phil Wilson, (Apress, ISBN: 1590592972). Check it out at your favorite bookstore today. Buy this book now. |
Next: More About Properties >>
More Visual Basic.NET Articles
More By Apress Publishing