[EMAIL PROTECTED] skrev: > Hi, > > I wish to write a Python wrapper for my C# COM object but am unsure > where to start. I have a dll and a tlb file, and I can use this object > in C via the following code - > > // ConsolApp.cpp : Defines the entry point for the console application. > // > #include "stdafx.h" > #include "windows.h" > #include "stdio.h" > #import "C:\Documents and Settings\X\Mina dokument\Visual Studio > 2005\Projects\X_COMObject\X_COMObject\bin\Debug\X_COMObject.tlb" > using namespace X_COMObject; > > int _tmain(int argc, _TCHAR* argv[]) > { > CoInitialize(NULL); > > X_COMObject::XCOM_InterfacePtr p(__uuidof(X_COMObject::XCOM_Class)); > XCOM_Interface *X_com_ptr ; > X_com_ptr = p ; > X_com_ptr->SetID(10); > int x = X_com_ptr->GetID(); > printf("%d",x); > getchar(); > > return 0; > } > > Can anyone offer me some tips as to how to do this in Python? > > Thanks very much for your help, > > Barry.
This is what I've done so far, but I know I'm not doing this correctly. Can anyone help me out? #import pythoncom #pythoncom.CoInitialize() from comtypes.client import GetModule, CreateObject module = GetModule("C:\\Documents and Settings\\X\\Mina dokument\\Visual Studio 2005\\Projects\\X_COMObject\\X_COMObject\\bin\\Debug\\X_COMObject.tlb") dir(module) interface = module.XCOM_Interface() dir(interface) interface.SetID() #pythoncom.CoUnitialize() Traceback (most recent call last): File "C:/Python25/test.py", line 14, in <module> interface.SetID() TypeError: Expected a COM this pointer as first argument -- http://mail.python.org/mailman/listinfo/python-list