@@ -29,13 +29,46 @@ def init():
2929 except WindowsError as e :
3030 t = e .winerror
3131 if t :
32- return t
32+ return t & 0xffffffff
3333 return initsecurity ()
3434
3535def initsecurity (): # Should take some parameters..
3636 return winproxy .CoInitializeSecurity (0 , - 1 , None , 0 , 0 , RPC_C_IMP_LEVEL_IMPERSONATE , 0 ,0 ,0 )
3737
3838
39+ class Dispatch (interfaces .IDispatch ):
40+ def TypeInfoCount (self ):
41+ count = gdef .UINT ()
42+ self .GetTypeInfoCount (count )
43+ return count
44+
45+ def type_info (self , idx ):
46+ type_info = TypeInfo ()
47+ self .GetTypeInfo (idx , 0 , type_info )
48+ return type_info
49+
50+ class TypeInfo (interfaces .ITypeInfo ):
51+ def func (self , idx ):
52+ res = gdef .LPFUNCDESC ()
53+ self .GetFuncDesc (idx , res )
54+ return res
55+
56+ def attr (self ):
57+ res = gdef .LPTYPEATTR ()
58+ self .GetTypeAttr (res )
59+ return res
60+
61+ def names (self , memid ):
62+ size = gdef .UINT ()
63+ x = (gdef .BSTR * 10 )(* tuple (gdef .BSTR () for i in range (10 )))
64+ self .GetNames (memid , x , 10 , size )
65+ return x [:size .value ]
66+
67+ def docu (self , id ):
68+ res = gdef .BSTR ()
69+ self .GetDocumentation (id , res , None , None , None )
70+ return res
71+
3972def create_instance (clsiid , targetinterface , custom_iid = None , context = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER ):
4073 """A simple wrapper around ``CoCreateInstance <https://msdn.microsoft.com/en-us/library/windows/desktop/ms686615(v=vs.85).aspx>``"""
4174 if custom_iid is None :
@@ -196,6 +229,12 @@ def get_value_based_on_type(self):
196229 attr = self .QUICK_CHECK_TYPE [rawvt ]
197230 if attr is None :
198231 return None
232+ if attr == "punkVal" :
233+ # Quick hack for COM interface type
234+ # Do something clean with CHECK_TYPE ?
235+ x = gdef .IUnknown (self .punkVal )
236+ x .AddRef ()
237+ return x
199238 return getattr (self , attr )
200239
201240 def guess_type_and_set_value (self , value ):
0 commit comments