| 771 | |
| 772 | |
| 773 | class IDispatch(IUnknown): |
| 774 | _disp_methods_: ClassVar[list["_DispMemberSpec"]] |
| 775 | |
| 776 | _iid_ = GUID("{00020400-0000-0000-C000-000000000046}") |
| 777 | _methods_ = [ |
| 778 | COMMETHOD([], HRESULT, "GetTypeInfoCount", (["out"], POINTER(UINT))), |
| 779 | COMMETHOD( |
| 780 | [], |
| 781 | HRESULT, |
| 782 | "GetTypeInfo", |
| 783 | (["in"], UINT, "index"), |
| 784 | (["in"], LCID, "lcid", 0), |
| 785 | # Normally, we would declare this parameter in this way: |
| 786 | # (['out'], POINTER(POINTER(ITypeInfo)) ) ), |
| 787 | # but we cannot import comtypes.typeinfo at the top level (recursive imports!). |
| 788 | (["out"], POINTER(POINTER(IUnknown))), |
| 789 | ), |
| 790 | STDMETHOD( |
| 791 | HRESULT, |
| 792 | "GetIDsOfNames", |
| 793 | [POINTER(IID), POINTER(c_wchar_p), UINT, LCID, POINTER(DISPID)], |
| 794 | ), |
| 795 | STDMETHOD( |
| 796 | HRESULT, |
| 797 | "Invoke", |
| 798 | [ |
| 799 | DISPID, |
| 800 | POINTER(IID), |
| 801 | LCID, |
| 802 | WORD, |
| 803 | POINTER(DISPPARAMS), |
| 804 | POINTER(VARIANT), |
| 805 | POINTER(EXCEPINFO), |
| 806 | POINTER(UINT), |
| 807 | ], |
| 808 | ), |
| 809 | ] |
| 810 | |
| 811 | if TYPE_CHECKING: |
| 812 | |
| 813 | def GetTypeInfoCount(self) -> int: ... |
| 814 | |
| 815 | def GetTypeInfo(self, index: int, lcid: int = 0) -> "hints.ITypeInfo": |
| 816 | """Return type information. Index 0 specifies typeinfo for IDispatch""" |
| 817 | import comtypes.typeinfo |
| 818 | |
| 819 | result = self._GetTypeInfo(index, lcid) # type: ignore |
| 820 | return result.QueryInterface(comtypes.typeinfo.ITypeInfo) |
| 821 | |
| 822 | def GetIDsOfNames(self, *names: str, **kw: Any) -> list[int]: |
| 823 | """Map string names to integer ids.""" |
| 824 | lcid = kw.pop("lcid", 0) |
| 825 | assert not kw |
| 826 | arr = (c_wchar_p * len(names))(*names) |
| 827 | ids = (DISPID * len(names))() |
| 828 | self.__com_GetIDsOfNames(riid_null, arr, len(names), lcid, ids) # type: ignore |
| 829 | return ids[:] |
| 830 | |