Reading .lnk files
Mark Hammond
mhammond at skippinet.com.au
Tue Nov 2 17:43:37 EST 1999
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
More information about the Python-list
mailing list