抑制 ShellLink 中的 Windows 对话框 Resolve with missing target in ShellLink?
Suppress Windows dialog in ShellLink Resolve with missing target in ShellLink?
在Delphi XE7中,我想用下面的代码来替换shell link文件(.lnk)的link目标:
uses
JclShell;
...
procedure ShellLinkReplaceLinkTarget(const AShellLinkFile, ANewTarget: string);
var
ThisShellLink: JclShell.TShellLink;
begin
if (JclShell.ShellLinkResolve(AShellLinkFile, ThisShellLink) = S_OK) then // Windows error dialog
begin
ThisShellLink.Target := ANewTarget;
JclShell.ShellLinkCreate(ThisShellLink, AShellLinkFile);
end
else CodeSite.Send('ShellLinkResolve Failed!');
end;
然而,当 link 目标不再存在时,然后在 ShellLinkResolve
出现众所周知的 Link problem
Windows 错误对话框,告诉 link 目标已被删除等。这是德语对话框:
那么我怎样才能禁止这个对话框呢?因为程序需要用另一个替换缺少的 link 目标,而不是 Windows.
Windows 7 x64 SP1
编辑:
顺便说一句:当我点击 Restore
按钮(上面对话框屏幕截图中最左边的按钮)时,丢失的目标将从废纸篓中恢复 - 但成功后对话框不会关闭还原或至少在还原后禁用还原按钮。 Microsoft UI 糟糕设计的示例。
试试下面的代码:
if (JclShell.ShellLinkResolve(AShellLinkFile, ThisShellLink,
SLR_ANY_MATCH or SLR_NO_UI) = S_OK) then
在Delphi XE7中,我想用下面的代码来替换shell link文件(.lnk)的link目标:
uses
JclShell;
...
procedure ShellLinkReplaceLinkTarget(const AShellLinkFile, ANewTarget: string);
var
ThisShellLink: JclShell.TShellLink;
begin
if (JclShell.ShellLinkResolve(AShellLinkFile, ThisShellLink) = S_OK) then // Windows error dialog
begin
ThisShellLink.Target := ANewTarget;
JclShell.ShellLinkCreate(ThisShellLink, AShellLinkFile);
end
else CodeSite.Send('ShellLinkResolve Failed!');
end;
然而,当 link 目标不再存在时,然后在 ShellLinkResolve
出现众所周知的 Link problem
Windows 错误对话框,告诉 link 目标已被删除等。这是德语对话框:
那么我怎样才能禁止这个对话框呢?因为程序需要用另一个替换缺少的 link 目标,而不是 Windows.
Windows 7 x64 SP1
编辑:
顺便说一句:当我点击 Restore
按钮(上面对话框屏幕截图中最左边的按钮)时,丢失的目标将从废纸篓中恢复 - 但成功后对话框不会关闭还原或至少在还原后禁用还原按钮。 Microsoft UI 糟糕设计的示例。
试试下面的代码:
if (JclShell.ShellLinkResolve(AShellLinkFile, ThisShellLink,
SLR_ANY_MATCH or SLR_NO_UI) = S_OK) then