Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Win32 Shortcuts (.lnk files) with com in python (See related posts)

Class and general usage for accessing windows shortcuts in Python.

import pythoncom

class Win32Shortcut:
    def __init__(self, lnkname):
        self.shortcut = pythoncom.CoCreateInstance(
            shell.CLSID_ShellLink, None,
            pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
        self.shortcut.QueryInterface(pythoncom.IID_IPersistFile).Load(lnkname)

    def __getattr__(self, name):
        return getattr(self.shortcut, name)

s = Win32Shortcut(path)
iconPath = s.GetIconLocation()[0]
itemPath = s.GetPath(0)[0]




You need to create an account or log in to post comments to this site.


Related Posts