Reading .lnk files
mhammond at skippinet.com.au
Tue Nov 2 19:07:03 EST 1999
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.
> -----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.
> # DumpShortcut.py
> # A demo of how to dump a shortcut using Python.
> # This code dumps the shortcut specificed as sys.argv
> 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)
> # Get the data
> print "Path name:", sh.GetPath(shell.SLGP_SHORTPATH)
> print "Args:", sh.GetArguments()
> print "Description:", sh.GetDescription()
> print "Working directory:", sh.GetWorkingDirectory()
> if __name__=='__main__':
> import sys
> # 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
> Working directory: L:\src\python-cvs\tools\idle
More information about the Python-list