[pywin32-bugs] [ pywin32-Bugs-1119908 ] CastTo/QueryInterface problem
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2005-02-10 09:14:02
|
Bugs item #1119908, was opened at 2005-02-10 09:06 Message generated for change (Comment added) made by oleaw You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1119908&group_id=78018 Category: win32 Group: None Status: Open Resolution: None Priority: 5 Submitted By: oleaw (oleaw) Assigned to: Nobody/Anonymous (nobody) Summary: CastTo/QueryInterface problem Initial Comment: In the COM API I am using, the following is provided: To create a new patient object I have to cast the Patient manager interface to the IDIContstructor interface. PatMgr: IDIPatientMgr; NewPat: IDIPatient; ... PatMgr := DISession.GetManagerById(miPatient) as IDIPatientMgr; NewPat := (PatMgr as IDIConstructor).CreateNew as IDIPatient; //edit the patient... //Save the changes (NewPat as IDIEdit).Save; In python I have written the following code. miPerson = 26 try: PersonMgr except NameError: PersonMgr = self.__dips_api.GetManagerById(miPerson) else: print "PersonMgr eksisterer" NewPerson = CastTo(PersonMgr, 'IDIPersonMgr') This casts PersonMgr to the right Interface. My problem is that once I use the CastTo function all of my other functions cease to work. Apparently all the objects are wrapped in PyIUnkown, and python is no longer able to find their appropriate type. This problem will persist until delete the automatically generated python COM code and restart IDLE. All the interfaces I am using are IDispatch. I have also tried to alternatively cast the interface with PersonMgr.QueryObject(IDIConstructor) and Dispatch(PersonMgr , None, 'IDIContructor'), but these functions are unable to find the interface. Have also tried with makepy Can anyone provide information on how to make CastTo work, (can I unwrap the PyIUnknown wrapper?) Ole A ---------------------------------------------------------------------- >Comment By: oleaw (oleaw) Date: 2005-02-10 09:14 Message: Logged In: YES user_id=1216110 The line NewPerson = CastTo(PersonMgr, 'IDIPersonMgr') is NewPerson = CastTo(PersonMgr, 'IDIConstructor') and IDIContructor should be IDIConstructor This however is not the problem Ole A ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1119908&group_id=78018 |