gpt4 book ai didi

windows-10 - Inno setup 无法在 Windows 10 中创建桌面图标

转载 作者:行者123 更新时间:2023-12-03 11:23:15 25 4
gpt4 key购买 nike

我有用于最新版本的 inno 设置的设置文件。它从 windows xp 到 windows 8 都可以编译并运行良好,但在 windows 10 中,它在创建桌面图标时失败,并出现下一个错误:
IPersistFile::保存失败;代码 0x80070002

这就是我在安装文件中创建图标的方式:

[Icons]
Name: "{userdesktop}\Forex Tester 4"; Filename: "{app}\ForexTester4.exe"; Tasks: desktopicon

部分安装日志文件:
2019-02-01 12:50:46.376   -- Icon entry --
2019-02-01 12:50:46.376 Dest filename: C:\Users\Mike\Desktop\Forex Tester 4.lnk
2019-02-01 12:50:46.376 Creating the icon.
2019-02-01 12:50:46.376 Exception message:
2019-02-01 12:50:46.376 Message box (OK):
IPersistFile::Save failed; code 0x80070002.
The system cannot find the file specified.
2019-02-01 12:50:59.066 User chose OK.

该文件夹存在,我可以在那里手动创建文件。但是 inno setup 无法做到这一点......除了桌面图标之外的所有其他图标都没有问题。

有任何想法吗?

最佳答案

我在 Windows 7 和 Windows 10 上遇到了同样的错误,因为我试图创建尚不存在的文件的快捷方式。

[Icons]
; Create icons for the app
Name: "{group}\{#AppName}"; \
Filename: "{app}\{#AppName}.lnk"; \
BeforeInstall: CreateAppRunLink();
Name: "{commondesktop}\{#AppName}"; \
Filename: "{app}\{#AppName}.lnk"; \
Tasks: desktopicon;

所以我必须在创建图标之前确保文件“{app}{#AppName}.lnk”存在:
这转到 [代码] 部分:
procedure CreateAppRunLink();
var
Filename: string;
Description: string;
ShortcutTo: string;
Parameters: string;
WorkingDir: string;
IconFilename: string;
begin
Filename := ExpandConstant('{app}\MyApp.lnk');
Description := 'Description';
ShortcutTo := 'Full path to file that will be run (MyApp.exe)';
Parameters := 'parameters if any';
WorkingDir := ExpandConstant('{app}');
IconFilename := ExpandConstant('{app}') + '\icon.ico';

CreateShellLink(Filename, Description, ShortcutTo, Parameters, WorkingDir,
IconFilename, 0, SW_HIDE);
end;

CreateAppRunLink 将在从 [Files] 部分提取任何文件后调用,这将确保我们的文件就位。

希望这会有所帮助。

关于windows-10 - Inno setup 无法在 Windows 10 中创建桌面图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54484900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com