def create_shortcut(shell_item, shortcut_path):
    id_list = shell.SHGetIDListFromObject(shell_item)
    shortcut = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None,
        pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
    shortcut.SetIDList(id_list)
    persist = shortcut.QueryInterface(pythoncom.IID_IPersistFile)
    persist.Save(shortcut_path, 0)
Beispiel #2
0
 def test_idlist_roundtrip(self):
     pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP)
     item = shell.SHCreateItemFromIDList(pidl, shell.IID_IShellItem)
     pidl_back = shell.SHGetIDListFromObject(item)
     self.assertEqual(pidl, pidl_back)