AW: win32com.client.pythoncom.CoCreateInstance
Stefan Migowsky
smigowsky at dspace.de
Thu Aug 3 02:59:33 EDT 2000
Hi,
did you try the constants defined in pythoncom, e.g.
def CreateShortCut(Path, Target,Arguments = "", StartIn = "", Icon = ("",0),
Description = ""):
from win32com.shell import shell
import pythoncom
# Get the shell interface.
sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, \
pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
# Get an IPersist interface
persist = sh.QueryInterface(pythoncom.IID_IPersistFile)
# Set the data
sh.SetPath(Target)
sh.SetDescription(Description)
sh.SetArguments(Arguments)
sh.SetWorkingDirectory(StartIn)
sh.SetIconLocation(Icon[0],Icon[1])
# Save the link itself.
persist.Save(Path, 1)
Stefan
-----Ursprüngliche Nachricht-----
Von: musingattheruins at my-deja.com [mailto:musingattheruins at my-deja.com]
Gesendet: Mittwoch, 2. August 2000 17:22
An: python-list at python.org
Betreff: win32com.client.pythoncom.CoCreateInstance
does anyone have any idea why this does not work? i am trying to get a
handle to the IShellLinkA interface that will allow me to create
shortcuts but the COM code seems to have a problem.
any help would be greatly appreciated!
import win32com.client, pywintypes
#win32com.client.pythoncom.CoInitialize()
CLSID_ShellLink = pywintypes.IID("{00021401-0000-0000-C000-
000000000046}")
iShellLink = pywintypes.IID("{000214EE-0000-0000-C000-
000000000046}")
create_as = win32com.client.pythoncom.CLSCTX_INPROC_SERVER
i = win32com.client.pythoncom.CoCreateInstance(CLSID_ShellLink, None,
create_as, iShellLink)
here is the error that it returns...
Traceback (innermost last):
File "<stdin>", line 1, in ?
TypeError: There is no interface object registered that supports this
IID
the registry lists both of these guids and the shell32.dll exists; i
can create shortcuts manually.
thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
--
http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list