Re: How to create a relative shortcut ?
Schugo <[email protected]> Sat, 6 Sep 2025 18:58:35 +0200
| Newsgroups | comp.os.ms-windows.programmer.win32,alt.comp.os.windows-xp,alt.windows7.general |
|---|---|
| Organization | A noiseless patient Spider |
| Message-ID | <[email protected]> |
On 05.09.2025 21:05, R.Wieser wrote: > "R.Wieser" wrote : > >> Hello all, >> >> I'm trying to create relative shortcuts* (for use on a removable USB >> harddisk) and can't seem to find out how it works. > > It looks like I ran head-first into some "over-engenering". :-( > > As I could not find any way to create a relative shortcut using the > IShellLink object, I took a better look at the Shortcut file itself. And > going on a hunch, I was able to solve the problem in the most basic way ever > : by manually creating a shortcut file. > > It turns out that writing the header with only the "HasRelativePath" flag > set and than the desired (counted-length) relative path followed by four > bytes all Zero (as the end of extras list of blocks) does the trick. > > Adding other strings (arguments, working directory, description) the same > way also works. > > One downside though : when going into the properties and changing the target > causes the shortcut to revert to its normal, absolute paths format. > > ... At least, here on my XPsp3 machine. congrats! good to know. ciao..