[python-win32] Creating a TLB for PythonCOM server
Mark Hammond
skippy.hammond at gmail.com
Sat Dec 18 02:48:26 CET 2010
You should probably check out the "pippo" examples in the win32com\test
directory for an example of associating the python COM object with the
typelib.
HTH,
Mark
On 16/12/2010 12:08 PM, Mariano Reingart wrote:
> Hello
>
> I'm trying to create a type library (TLB) using MIDL.EXE for a
> PythonCom server, but I don't fully understand the brief MSDN
> ducumentation:
> http://msdn.microsoft.com/en-us/library/ms690150(v=VS.85).aspx
>
> I've been able to create the TLB file, but when using it in VB, I get
> a Run-time error '13': "Type mismatch" with this code:
>
> Dim WSAA As PyAfipWs.WSAA
> Set WSAA = CreateObject("WSAA")
> Debug.Print WSAA.Version
>
> Testing it with python, makepy.py sucessfully creates the python
> classes, but it doesn't use them when I do:
>
> win32com.client.Dispatch("WSAA")
>
> Following is the code in question:
>
> Python COM server (stripped version):
> -------------------------------------
>
> class WSAA:
> _public_methods_ = ['CreateTRA']
> _public_attrs_ = _readonly_attrs_ = ['Version']
> _reg_progid_ = "WSAA"
> _reg_clsid_ = "{6268820C-8900-4AE9-8A2D-F0A1EBD4CAC5}"
>
> def __init__(self):
> self.Version = "1234"
>
> def CreateTRA(self, service="wsfe", ttl=2400):
> return "pass"
>
>
> full code at:
> http://code.google.com/p/pyafipws/source/browse/pyafipws.py
>
>
> IDL file (stripped version):
> ----------------------------
>
> import "unknwn.idl","oaidl.idl";
> [
> uuid(6268820C-8900-4AE9-8A2D-F0A1EBD4CAC5),
> helpstring("PyAfipWs WSAA interface"),
> pointer_default(unique),
> //dual,
> //oleautomation
> object
> ]
> interface WSAAif : IDispatch //IUnknown
> {
> HRESULT CreateTRA([in] VARIANT service, [in] VARIANT ttl,
> [out, retval] VARIANT * tra);
> [propget] HRESULT Version( [out, retval] VARIANT * sign);
> };
>
> [
> uuid(a03d1423-b1ec-11d0-8c3a-00c04fc31d2f),
> version(1.0),
> helpstring("PyAfipWs Type Library"),
> ] library PyAfipWs
> {
> importlib("stdole32.tlb");
> [
> uuid(a03d1422-b1ec-11d0-8c3a-00c04fc31d2f),
> helpstring("WSAA Component Class")
> ] coclass WSAA
> {
> [default]interface WSAAif;
> }
> }; //end library def
>
>
>
> I think I'm missing something and surely I'm doing something wrong
> (related to IUnknown/IDispatch, dual/oleautomation/object, CLSID,
> PROGID, etc.). I've tested many combinations and none seems to work.
>
>
> Do you have any advice?
>
>
> Thanks in advance,
>
> Mariano Reingart
> http://www.sistemasagiles.com.ar
> http://reingart.blogspot.com
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
More information about the python-win32
mailing list