def resolve_shortcut(filename):
"""resolve_shortcut("Notepad.lnk") => "C:\WINDOWS\system32\notepad.exe"
Returns the path refered to by a windows shortcut (.lnk) file.
"""
shell_link = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink, None,
pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
persistant_file = shell_link.QueryInterface(pythoncom.IID_IPersistFile)
persistant_file.Load(filename)
shell_link.Resolve(0, 0)
linked_to_file = shell_link.GetPath(shell.SLGP_UNCPRIORITY)[0]
return linked_to_file
评论列表
文章目录