Reading .lnk files

Mark Hammond mhammond at skippinet.com.au
Tue Nov 2 21:31:44 EST 1999


OK - thanks everyone - it seems certain that the code does indeed
work, and that the problem was something specific to Ivan - quite
possibly his use of the MKS shell.  Ive had positive responses from
NT, 98 and 95 now.

Thanks,

Mark.

[I wrote]
> Ivan has mailed me that this does not work for him (dies with a big
> crash!).  If anyone else has a spare moment, could you please try
this
> code and see if it works?  Whether it does or not, please also
include
> info on the OS you tried it on.  Please mail me personally with this
> info, and I will summarize back to the list.
>
> Thanks,
>
> Mark.
>
> > -----Original Message-----
> > From: python-list-admin at python.org
> > [mailto:python-list-admin at python.org]On Behalf Of Mark Hammond
> > Sent: Wednesday, 3 November 1999 9:44
> > To: 'Ivan Van Laningham'; 'Python Mailing List'
> > Subject: RE: Reading .lnk files
> >
> >
> > Sure is.  For more details, see the COM help file on PyIShellLink.
> >
> > Mark.
> >
> > # DumpShortcut.py
> > # A demo of how to dump a shortcut using Python.
> >
> > # This code dumps the shortcut specificed as sys.argv[1]
> >
> > from win32com.shell import shell
> > import pythoncom
> >
> > def DumpIt(fileName):
> > # Get the shell interface.
> >     sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, \
> >       pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
> >
> >     # Get an IPersist interface
> >     persist = sh.QueryInterface(pythoncom.IID_IPersistFile)
> >
> >     persist.Load(fileName)
> >
> >     # Get the data
> >     print "Path name:", sh.GetPath(shell.SLGP_SHORTPATH)[0]
> >     print "Args:", sh.GetArguments()
> >     print "Description:", sh.GetDescription()
> >     print "Working directory:", sh.GetWorkingDirectory()
> >
> > if __name__=='__main__':
> >     import sys
> >     DumpIt(sys.argv[1])
> >
> > # demo of usage:
> > C:\>DumpShortcut.py IDLE.lnk
> > Path name: L:\src\PYTHON~1.2\PCbuild\pythonw.exe
> > Args: l:\src\python-cvs\tools\idle\idle.pyw
> > Description:
> > Working directory: L:\src\python-cvs\tools\idle
> >
> >
> > --
> > http://www.python.org/mailman/listinfo/python-list
> >
>
>
> --
> http://www.python.org/mailman/listinfo/python-list
>





More information about the Python-list mailing list