| Rob Dixon 2008-01-26, 10:09 pm |
| Tom Phoenix wrote:
> 2008/1/25 Chen Yue <godsarmycy@gmail.com>:
>
>
> You'd think so; symbolic links have a simple implementation on
> Unix-like machines. Besides, Windows itself can figure it out. Unless
> Microsoft have hidden a key piece of the puzzle from us, we should be
> able to do it as well.
>
> Alas, the file format is, it seems, proprietary. Here's a reverse engineering:
>
> http://www.i2s-lab.com/Papers/The_W...File_Format.pdf
>
> To quote from that document:
>
> If you're writing software under Windows I highly recommend you
> use the IShellLink interface. For the DOS, Linux, JAVA and other
> crowds, this is the document you need, 'cause MS isn't gonna
> give you squat.
>
> Somebody should probably make a module for that "IShellLink
> interface", and pulling data from the .lnk file format probably
> deserves a module of its own. Neither type of module seems to be
> available on CPAN yet.
>
> Hope this helps!
Unfortunately a Microsoft link file is an encapsulation of a
command-line instead of being a simple reference to another file. It
includes information like working directory, parameter values, and the
icon to be displayed.
There is, however, a Win32::Shortcut module in the libwin32 bundle that
I have used successfully. If all you want is the path to the linked file
then you can something like the program below.
HTH,
Rob
use strict;
use warnings;
use Win32::Shortcut;
my $file = 'C:\Documents and Settings\Rob\Desktop\Perl.lnk';
print link_path($file), "\n";
sub link_path {
Win32::Shortcut->new(@_)->Path;
}
|