Hello, I'm trying to get the target filename of windows shortcuts. The code below works great for regular shortcuts, but errors out on "folder shortcuts". (for what I mean, see: https://superuser.com/questions/456399/what-different-types-of-shortcut-are-there/639967#639967)
The code below works great for regular .lnk shortcuts, but folder shortcuts give me: [...] persistFile.Load(fname,STGM_READ) pywintypes.com_error: (-2147024891, 'Access is denied.', None, None) The quirk with folder shortcuts is they have some DOS attributes set, which I suspect could be causing me trouble. Is there, perhaps, something I need to do to get my IPersistFile to ignore file attributes? Or is this error a result of something else? ----- teh code def linkinfo(path): """ returns (isLink,targetPath) """ path=os.path.abspath(path) targetPath=path fname=path isLink=False desktop=shell.SHGetDesktopFolder() _,pidl,_=desktop.ParseDisplayName(None,None,path) shell_item =shell.SHCreateShellItem(None,None,pidl) attrs=shell_item.GetAttributes(shellcon.SFGAO_LINK|shellcon.SFGAO_FOLDER) isLink=attrs&shellcon.SFGAO_LINK>0 isFolder=attrs&shellcon.SFGAO_FOLDER>0 if isLink and not fname.endswith('URL'): shellLink=pythoncom.CoCreateInstance(shell.CLSID_ShellLink,None,pythoncom.CLSCTX_INPROC_SERVER,shell.IID_IShellLink) persistFile=shellLink.QueryInterface(pythoncom.IID_IPersistFile) if isFolder: fname=fname+os.sep+'target.lnk' persistFile.Load(fname,STGM_READ) targetPath,findData=shellLink.GetPath(0) return isLink,targetPath _______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32