In Delphi XE7, I want to use the following code to change the link target of a shell link file (.lnk),
< P> Even if the link target is not present:
uses JclShell; ... process ShellLinkReplaceLinkTarget (Const. AShellLinkFile, ANewTarget: string); Var This Shihal Link: Jensey Shell link; Start (JclShell.ShellLinkResolve (AShellLinkFile, ThisShellLink, SLR_ANY_MATCH or SLR_NO_UI) = S_OK) then start this link. Goal: = ANETarget; JclShell.ShellLinkCreate (This Shell Link, AShellLinkFile); And Seedite End ('shell link revolve fail!'); End; Obviously, it is not possible to get the link from the link code with the ShellLinkResolve
, when the link target no longer exists, as explained by Dawood, please. So how can I get the data from the link file in this case?
Why do not you want to use very simple code like this:
< Pre> process ShellLinkReplaceLinkTarget (CONST ASHEL LINKFile, ANEETTAG: UnicodeString); Var Shell Link: ISL Links; PersistFile: iPhones File; OleCheck (CoCreateInstance (CLSID_Shell Link, Zero, CLSCTX_INPROC_SERVER, IShellLinkW, ShellLink)); Try OLECheck (ShellLink.QInterface (iPharfsFile, Persistfile); Try OderCheck (ShellLink.SetIDList (Zero)); OleCheck (ShellLink.SetPath (PWideChar (ANewTarget) Finally, the persist file: = zero; finished; shell link at the end: = zero; finished; end;
And there is a very important description in some lnk files, such as various properties Background color (in Windows 8) and if you want to recreate the lnk file properties will be lost.
No comments:
Post a Comment