[Fwd: odd behavior of symlinks on Win XP SP2]

Corinna Vinschen vinschen@redhat.com
Tue Jan 18 13:17:00 GMT 2005

----- Forwarded message from Jeff Hodges -----
> Date: Fri, 14 Jan 2005 15:50:08 -0800
> From: Jeff Hodges
> Subject: odd behavior of symlinks on Win XP SP2
> To: cygwin@cygwin.com
> Reply-To: cygwin@cygwin.com
> [...]
> 1. cygwin-created (via "ln -s") symlinks/shortcuts pointing to a directory are 
> displayed in windows file dialogs with the windows default "funky file" icon 
> (I dunno what it's actual name is) rather than the windows folder icon as used 
> to be the case on win2k/cygwin.
> 2. cygwin-created (via "ln -s") symlinks/shortcuts pointing to a directory are 
> displayed in some windows file-open or file-save dialogs, but not in others. 
> On win2k/cygwin, they were always displayed and always behaved exactly like 
> windows-created shortcuts pointing to a directory. In terms of how they are 
> behaving on WinXP/cygwin..
> [etc.]
----- End forwarded message -----

I've just commited a patch.  I've found an interesting document on the
net ("The Windows Shortcut File Format" by Jesse Hager) which gave me
some insight into the shortcut files.  I found that XP requires the
shortcuts to contain an ITEMIDLIST to react correctly in file open
dialogs and to show the correct icon in Windows Explorer.
Unfortunately ITEMIDLIST is a pretty hairy and undocumented structure,
so I have to call shell32 functions to create it.  I've tried to speed
up the whole process by calling WriteFile only once and I hope I have
also sped up reading shortcuts by using ReadFile only once.

Please give it a test.  It looks good to me but I'm not sure I'm covering
all edges.

Btw., XP's Explorer apparently writes Unicode strings in the path and
description fields when creating a shortcut.  It seems that the 0x80
bit in the flags member of the shortcut header indicates that.  But that's
not mentioned in the above document so I left it out of the enum containing
the flag bit values.  I'd like to add it for documentary purposes if
somebody can point me to another documentation which contains that.  And,
who knows, one day Cygwin perhaps also creates Unicode shortcuts...


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          mailto:cygwin@cygwin.com
Red Hat, Inc.

More information about the Cygwin-developers mailing list