Shared Shortcuts/Icons

2019-05-26 10:02发布

I have several inno setups with shared files. With the 'Sharedfile' flag a can make sure that the they only get uninstalled if they're no longer used.

However this is not working for shortcuts or icons as they are called in inno pointing to those files. shortcuts are always getting removed even if the target file is not getting uninstalled.

So is there something i'm missing? a flag for shortcuts?

or do you have some starting point on how to prevent this in code?

Thanks a lot

标签: inno-setup
1条回答
甜甜的少女心
2楼-- · 2019-05-26 10:28

Thanks alot TLama this seems to be working:

I prevent my shard icons from being uninstalled with the 'uninsneveruninstall' flag.
Then in pascal, check if the file still exists if not manually delete the shortcut or folder:

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
    begin
        if CurUninstallStep = usPostUninstall then
            begin
                if (not(FileExists(ExpandConstant('{app}\executable1.exe')))) then DelTree(ExpandConstant('{group}\myfolder'), True, True, True);
                if (not(FileExists(ExpandConstant('{app}\executable2.exe')))) then DeleteFile(ExpandConstant('{group}\myShortcut.lnk');
            end;
    end;

Personally i think that inno setup should do this by default, checking if the installed shortcuts target is reference counted and use this value for the shortcut.

But anyhow thank you all very much and have a nice day.

查看更多
登录 后发表回答