in reply to How do I create a Win32 'shortcut' (.LNK) file?

You've probably found it by now (it's been 2 years since you posted) but I'll write it down for others who may be looking for it :
my $LINK=new Win32::Shortcut();
$LINK->Set("c:\\yourprogramname",
            "list of arguments", 
            "c:\\wherever you want it to run from",
            "description",
            1, #window state (1 is normal)
            hex('55x0337'), #shorcut key*
            "",#icon file eg win32.dll
            0);#icon number in file
$LINK->Save("c:\justaname.lnk");
$LINK->Close();

* shortcut key : it's 2 bytes followed by the key's code (for example 0337 is Q). The first 2 bytes give you the mode but I didn't find any info on the web - all I read was that no one knew how it worked. I'm still looking for that piece of info though.
For extra information you can go to http://search.cpan.org/src/GSAR/libwin32-0.191/Shortcut/docs/reference.html

Replies are listed 'Best First'.
Re: Here's the code
by Foggy Bottoms (Monk) on Jun 12, 2003 at 13:42 UTC
    Actually I just found out how to interpret the shorcut key code more or less :
    What I previously wrote is wrong. It always should be 0x something and not 55xsomething (I don't know what overcame - I guess I wasn't paying attention).
    0x0359 : the digits in bold give you the mode (ie CTRL+ or CTRL+ALT+ ...) and the other two give the key in itself.
    Example:
    hex('0x0659') corresponds to CTRL+ALT+Y. 06 represents CTRL+ALT and 59 represents Y...
Re: Here's the code
by PhilHibbs (Hermit) on Aug 13, 2003 at 08:41 UTC
    Here's my version:
    my $Shift = 0x0100; my $Ctrl = 0x0200; my $Alt = 0x0400; my $LINK=new Win32::Shortcut(); $LINK->Set('c:\targetfile', '', # arguements 'c:\', # directory tto execute in 'Perl Shortcut', # description 1, # window state (1 is normal) $Shift+$Ctrl+ord('S'), # shorcut key '', # icon file eg win32.dll 0); # icon number in file my $shortfile = 'C:\WINNT\Profiles\PhilHibbs\Start Menu\Programs\Acces +sories\shortcut.lnk'; $LINK->Save($shortfile); # run Explorer targetting the file just created # system("Explorer /e,/select,$shortfile"); $LINK->Close();
    Is there a better way to do constants? I'm more familiar with C and C++ where idioms differ.
      Well, the way to declare constants in perl is as follows :
           use constant NAME => value;
      You can store those constants in a separate package file of course !