Re: [comtypes-users] Creating Shell Links using comtypes
Hi, just to let you know: I gave up on creating .lnk files using comtypes and instead use .url files with a local address. For my application placing such a file in the Windows startup folder they works just fine, and have the huge advantage of being simple text files. Thanks again for the help, Markus - 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=100url=/ ___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users
Re: [comtypes-users] Creating Shell Links using comtypes
On Mon, Nov 3, 2008 at 4:29 PM, MR Michael Robellard (5314) [EMAIL PROTECTED] wrote: I don't believe IShellLink uses Dispatch/automation objects, so you will have to import the tlb information Microsoft supplies the idl and h file in shobjidl.idl and shobjidl.h You can use midl to create a tlb from it. Then you should be able to load the tlb into comtypes. Thank you for your directions. I used midl ShObjIdl.idl to generate the ShObjIdl.tlb file. But when I try to load it with comtypes using from comtypes.client import GetModule GetModule('ShObjIdl.tlb') I get the following output: # Generating comtypes.gen._50A7E9B1_70EF_11D1_B75A_00A0C90564FE_0_1_0 # Generating comtypes.gen._00020430___C000_0046_0_2_0 # Generating comtypes.gen.stdole C:\Python25\lib\site-packages\comtypes\tools\codegenerator.py:477: UserWarning: Structure __MIDL_IOleAutomationTypes_0004: PACKING FAILED: total alignment (8/64) warnings.warn(message, UserWarning) Traceback (most recent call last): File auto.py, line 11, in module shell = GetModule( 'ShObjIdl.tlb' ) File C:\Python25\lib\site-packages\comtypes\client\_generate.py, line 112, in GetModule mod = _CreateWrapper(tlib, pathname) File C:\Python25\lib\site-packages\comtypes\client\_generate.py, line 187, in _CreateWrapper mod = _my_import(fullname) File C:\Python25\lib\site-packages\comtypes\client\_generate.py, line 26, in _my_import return __import__(fullname, globals(), locals(), ['DUMMY']) File C:\Python25\lib\site-packages\comtypes\gen\_50A7E9B1_70EF_11D1_B75A_00A0C90564FE_0_1_0.py, line 1101, in module assert sizeof(__MIDL_IOleAutomationTypes_0004) == 16, sizeof(__MIDL_IOleAutomationTypes_0004) AssertionError: 8 Any hints? Kind regards, Markus - 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=100url=/ ___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users
[comtypes-users] Creating Shell Links using comtypes
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. Kind regards, Markus [1] http://tgolden.sc.sabren.com/python/win32_how_do_i/create-a-shortcut.html - 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=100url=/ ___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users