comtypes
comtypes copied to clipboard
[restricted] in .IDL file
Hello,
I've had few problems with comtypes recently:
second problem was more intriguing: my object was working in dynamic dispatch mode, but not with specified interface, I got seemingly random crashes, but realized that wrong (neighbouring) methods seem to be called.
The part of .IDL file from "OLE/COM Object Viewer" looks like this: (note [restricted] void Missing12();)
interface _ScanningComInterface : IDispatch {
[id(00000000), propget,
custom(54FC8F55-38DE-4703-9C4E-250351302B1C, 1)]
HRESULT ToString([out, retval] BSTR* pRetVal);
[id(0x60020001)]
HRESULT Equals(
[in] VARIANT obj,
[out, retval] VARIANT_BOOL* pRetVal);
[id(0x60020002)]
HRESULT GetHashCode([out, retval] long* pRetVal);
[id(0x60020003)]
HRESULT GetType([out, retval] _Type** pRetVal);
[id(0x60020004)]
HRESULT GetLifetimeService([out, retval] VARIANT* pRetVal);
>>>>>> [restricted] void Missing12();
[id(0x60020006)]
HRESULT CreateObjRef(
[in] _Type* requestedType,
[out, retval] _ObjRef** pRetVal);
[id(0x60020007), propget]
HRESULT Manufacturer([out, retval] BSTR* pRetVal);
[id(0x60020008), propget]
HRESULT ModelName([out, retval] BSTR* pRetVal);
[id(0x60020009), propget]
HRESULT LiveStatus([out, retval] CameraLiveStatus* pRetVal);
[id(0x6002000a)]
HRESULT LiveStart();
[id(0x6002000b)]
HRESULT LiveStop();
[id(0x6002000c)]
HRESULT SnapShot();
this was not reflected in generated code, but inserting:
COMMETHOD([dispid(0x60020005)], HRESULT, 'Missing12'),
at proper place seems to have "solved" the problem.
class _ScanningComInterface(comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0.IDispatch):
_case_insensitive_ = True
_iid_ = GUID('{455E7FC5-4666-3EB5-9B7A-3F6B6AB9A382}')
_idlflags_ = ['hidden', 'dual', 'nonextensible', 'oleautomation']
_ScanningComInterface._methods_ = [
COMMETHOD([dispid(0x0), 'propget'], HRESULT, 'ToString',
( ['out', 'retval'], POINTER(BSTR), 'pRetVal' )),
COMMETHOD([dispid(0x60020001)], HRESULT, 'Equals',
( ['in'], VARIANT, 'obj' ),
( ['out', 'retval'], POINTER(VARIANT_BOOL), 'pRetVal' )),
COMMETHOD([dispid(0x60020002)], HRESULT, 'GetHashCode',
( ['out', 'retval'], POINTER(c_int), 'pRetVal' )),
COMMETHOD([dispid(0x60020003)], HRESULT, 'GetType',
( ['out', 'retval'], POINTER(POINTER(comtypes.gen._BED7F4EA_1A96_11D2_8F08_00A0C9A6186D_0_2_4._Type)), 'pRetVal' )),
COMMETHOD([dispid(0x60020004)], HRESULT, 'GetLifetimeService',
( ['out', 'retval'], POINTER(VARIANT), 'pRetVal' )),
>>>>>
COMMETHOD([dispid(0x60020006)], HRESULT, 'CreateObjRef',
( ['in'], POINTER(comtypes.gen._BED7F4EA_1A96_11D2_8F08_00A0C9A6186D_0_2_4._Type), 'requestedType' ),
( ['out', 'retval'], POINTER(POINTER(comtypes.gen._BED7F4EA_1A96_11D2_8F08_00A0C9A6186D_0_2_4._ObjRef)), 'pRetVal' )),
COMMETHOD([dispid(0x60020007), 'propget'], HRESULT, 'Manufacturer',
( ['out', 'retval'], POINTER(BSTR), 'pRetVal' )),
COMMETHOD([dispid(0x60020008), 'propget'], HRESULT, 'ModelName',
( ['out', 'retval'], POINTER(BSTR), 'pRetVal' )),
COMMETHOD([dispid(0x60020009), 'propget'], HRESULT, 'LiveStatus',
( ['out', 'retval'], POINTER(comtypes.gen._F7E45523_E342_460A_BF2D_E75E14B030B8_0_1_0.CameraLiveStatus), 'pRetVal' )),
COMMETHOD([dispid(0x6002000a)], HRESULT, 'LiveStart'),
COMMETHOD([dispid(0x6002000b)], HRESULT, 'LiveStop'),
COMMETHOD([dispid(0x6002000c)], HRESULT, 'SnapShot'),
Unfortunately, it is beyond my capability to provide proper patch for this. At least I hope that this information will be useful.
Regards
Jozef Vesely