Ejemplo n.º 1
0
        /// <summary>
        /// Creates the rows needed for WixInternetShortcut to work.
        /// </summary>
        /// <param name="core">The CompilerCore object used to create rows.</param>
        /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
        /// <param name="componentId">Identifier of parent component.</param>
        /// <param name="directoryId">Identifier of directory containing shortcut.</param>
        /// <param name="id">Identifier of shortcut.</param>
        /// <param name="name">Name of shortcut without extension.</param>
        /// <param name="target">Target URL of shortcut.</param>
        public static void CreateWixInternetShortcut(CompilerCore core, SourceLineNumberCollection sourceLineNumbers, string componentId, string directoryId, string shortcutId, string name, string target, InternetShortcutType type)
        {
            // add the appropriate extension based on type of shortcut
            name = String.Concat(name, InternetShortcutType.Url == type ? ".url" : ".lnk");
            
            Row row = core.CreateRow(sourceLineNumbers, "WixInternetShortcut");
            row[0] = shortcutId;
            row[1] = componentId;
            row[2] = directoryId;
            row[3] = name;
            row[4] = target;
            row[5] = (int)type;

            // Reference custom action because nothing will happen without it
            core.CreateWixSimpleReferenceRow(sourceLineNumbers, "CustomAction", "WixSchedInternetShortcuts");

            // make sure we have a CreateFolder table so that the immediate CA can add temporary rows to handle installation and uninstallation
            core.EnsureTable(sourceLineNumbers, "CreateFolder");

            // use built-in MSI functionality to remove the shortcuts rather than doing so via CA
            row = core.CreateRow(sourceLineNumbers, "RemoveFile");
            row[0] = shortcutId;
            row[1] = componentId;
            row[2] = CompilerCore.IsValidShortFilename(name, false) ? name : String.Concat(core.GenerateShortName(name, true, false, directoryId, name), "|", name);
            row[3] = directoryId;
            row[4] = 2; // msidbRemoveFileInstallModeOnRemove
        }