Markus Gritsch schrieb: > Hi, > > I would like to create shell links (.lnk) from my Python program. I > found the following solution at [1] which uses win32com: > > import os, sys > import pythoncom > from win32com.shell import shell, shellcon > > shortcut = pythoncom.CoCreateInstance ( > shell.CLSID_ShellLink, > None, > pythoncom.CLSCTX_INPROC_SERVER, > shell.IID_IShellLink > ) > shortcut.SetPath (sys.executable) > shortcut.SetDescription ("Python %s" % sys.version) > shortcut.SetIconLocation (sys.executable, 0) > > desktop_path = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0) > persist_file = shortcut.QueryInterface (pythoncom.IID_IPersistFile) > persist_file.Save (os.path.join (desktop_path, "python.lnk"), 0) > > I was trying to translate this to comtypes, but had absolutely no > success. It would be very nice, if someone could give me any advice > how to do this using comtypes.
I have now bit the bullet and implemented the IPersistFile (in comtypes.persist), IShellLinkA, IShellLinkW interfaces plus the ShellLink coclass in comtypes SVN. A usage example is at the bottom of the comtypes.shelllink file: http://comtypes.svn.sourceforge.net/viewvc/comtypes/trunk/comtypes/shelllink.py?revision=457&view=markup Thomas ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users