[python-win32] Access coclass interface?

Mark Hammond skippy.hammond at gmail.com
Tue Jan 21 00:42:34 CET 2014


The problem is that the DLL isn't registered (or not registered in a way 
it can be used in your current config).

First, check the bitted-ness of the library matches Python - eg, if you 
have a 64bit version of Python, the DLL will also need to be 64 bits 
(and ditto for 32 bits).  If that checks out OK, it may simply not be 
registered, so "regsvr32 path/to/filename.dll" might get you working.

HTH,

Mark

On 14/01/2014 12:04 AM, Khoroshyy Petro wrote:
> Thank you to your respond.
> I looked into the library I need using OLE explorer. At the and of my
> message I paste the intormation I got from there. Could anybody give me
> a tip how to access IJYMonoReqd interface.
> Thank you in advance
> Petro
> --------------
> // Generated .IDL file (by the OLE/COM Object Viewer)
> //
> // typelib filename: JYMono.dll
>
> [
>    uuid(D7E942DC-3716-4BC1-8DA2-08D273BDC501),
>    version(1.0),
>    helpstring("JYMono 1.0 Type Library"),
>    custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 83951780),
>    custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 1181570652)
> ]
> library JYMONOLib
> {
>     // TLib :     // TLib : JYSystemLib 1.0 Type Library :
>     // {638F5A15-35A6-4F7D-B8ED-B48A4CD4C619}
>    importlib("JYSystemLib.dll");
>     // Forward declare all types defined in this
>     // typelib
>     [
>      uuid(BFF968D4-7B20-4D16-BD3A-BDEFEB0863A4),
>      helpstring("Monochromator Class")
>     ]
>     coclass Monochromator {
>         [default] interface IJYMonoReqd;
>         [default, source] dispinterface _IJYDeviceReqdEvents;
>         };
> };
> -------------------------------------------------------
> [
>    uuid(BFF968D4-7B20-4D16-BD3A-BDEFEB0863A4),
>    helpstring("Monochromator Class")
> ]
> coclass Monochromator {
>     [default] interface IJYMonoReqd;
>     [default, source] dispinterface _IJYDeviceReqdEvents;
>     };
> 	
> ------------------------------------------------------------------
> [
>   uuid(7963F672-D074-4F67-B15C-AF022065927E),
>   helpstring("IJYMonoReqd Interface"),
>   dual
> ]
> dispinterface IJYMonoReqd {
>     properties:
>     methods:
>         [id(0x00000001), helpstring("Method Load")]
>         void Load();
>         [id(0x00000002), helpstring("Method Save")]
>         void Save();
>         [id(0x00000003), helpstring("Method OpenCommunicationsEx")]
>         void OpenCommunicationsEx(
>                         [in] jyCommType  __MIDL_0016,
>                         [in] int portNum,
>                         [in, optional]
> 		       .......
> ________________________________________________________________________
> On Fri, Jan 10, 2014 at 07:51:57PM +0100, Thomas Heller wrote:
>> Am 10.01.2014 15:26, schrieb Khoroshyy Petro:
>>> Hi list,
>>> I try to control a setup which consist of a  monochromator and a CCD camera.
>> [...]
>>>
>>> Now if I try to access a monochromator coclass from another libray in
>>> the same way I get com_error: (-2147221005.
>>> instrument =  win32com.client.Dispatch("JYMONOLib.IJYMonoReqd")
>>> or
>>> instrument =  win32com.client.Dispatch("JYMONOLib.Monochromator")
>>
>>
>> You can use ctypes.WinError to look up the error code if it known
>> to windows:
>>
>>>>> from ctypes import *
>>>>> raise WinError(-2147221005)
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in <module>
>> WindowsError: [Error -2147221005] Ungültige Klassenzeichenfolge
>>>>>
>>
>> In english this would read: 'Invalid class string'.
>>
>> This means that the COM runtime does not know about the
>> "JYMONOLib.IJYMonoReqd" and "JYMONOLib.Monochromator" names.
>>
>> Thomas
>>
>> _______________________________________________
>> python-win32 mailing list
>> python-win32 at python.org
>> https://mail.python.org/mailman/listinfo/python-win32
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
>



More information about the python-win32 mailing list