簡體   English   中英

我如何創建一個復選框,只有當它被選中時,安裝程序才會在 InstallShield 的 InstallScript 項目的桌面上創建快捷方式?

[英]How can I create a checkbox that only if it's checked the installer creates shortcuts on Desktop in InstallScript project in InstallShield?

這很奇怪,在 InstallShield 的 InstallScript 項目中,沒有帶有復選框的對話框,允許用戶選擇是否在安裝結束時在桌面、開始菜單或其他任何地方創建快捷方式,我從不想創建強制在桌面上為不需要的用戶創建快捷方式的安裝程序。

我也這樣做了。 首先,我修改了 SetupType 對話框以包含 2 個詢問快捷方式的復選框。 如果為真,他們應該創建適當的快捷方式。 我將這些鏈接到自定義屬性(SET_START_MENU_SHORTCUT 和 SET_DESKTOP_SHORTCUT),然后稍后在我附在下面的腳本中檢查這些屬性。 然后我讓安裝程序創建兩個快捷方式並刪除需要刪除的快捷方式。 這是 Revenera 告訴我使用的解決方案。

function SelectiveRemoveShortcuts(hMSI)
#define shortcutName "Launch Foo.exe"
STRING szCompany;
STRING szStartMenuPath;
STRING startMenuShortcut;
STRING szDesktop;
STRING szDesktopShortcut;
STRING nvSMProp;
string nvDesktopProp;
NUMBER nvSize;
begin
    nvSize = 1;
    szCompany = FOLDER_COMMON_APPDATA + "\\Start Menu\\Programs\\CompanyName\\";
    szStartMenuPath = szCompany + "Foo\\";
    startMenuShortcut = szStartMenuPath + shortcutName;
    szDesktop = FOLDER_DESKTOP;
    szDesktopShortcut = szDesktop + "\\"+shortcutName;
    MsiGetProperty(hMSI, "SET_START_MENU_SHORTCUT", nvSMProp, nvSize);
    MsiGetProperty(hMSI, "SET_DESKTOP_SHORTCUT", nvDesktopProp, nvSize); 
    if nvSMProp != "1" then
        DeleteShortcut(szStartMenuPath, shortcutName);
        DeleteDir(szStartMenuPath, ONLYDIR);
        DeleteDir(szCompany, ONLYDIR);
    endif;
    if nvDesktopProp != "1" then
        DeleteShortcut(szDesktop, shortcutName);
    endif;

end;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM