public override int GetDocumentation(int memid, IntPtr strName, IntPtr strDocString, IntPtr dwHelpContext, IntPtr strHelpFile) { if (memid == (int)KnownDispatchMemberIDs.MEMBERID_NIL) { if (strName != IntPtr.Zero) { RdMarshal.WriteIntPtr(strName, Marshal.StringToBSTR("_ArtificialContainer")); } if (strDocString != IntPtr.Zero) { RdMarshal.WriteIntPtr(strDocString, IntPtr.Zero); } if (dwHelpContext != IntPtr.Zero) { RdMarshal.WriteInt32(dwHelpContext, 0); } if (strHelpFile != IntPtr.Zero) { RdMarshal.WriteIntPtr(strHelpFile, IntPtr.Zero); } return((int)KnownComHResults.S_OK); } return((int)KnownComHResults.TYPE_E_ELEMENTNOTFOUND); }
public override int GetDocumentation(int memid, IntPtr strName, IntPtr strDocString, IntPtr dwHelpContext, IntPtr strHelpFile) { if (IsDispatchMemberIDInOurConstantsRange(memid)) { // this is very likely one of our simulated names from GetVarDesc() var fieldId = memid & _ourConstantsDispatchMemberIDIndexBitmask; if (strName != IntPtr.Zero) { RdMarshal.WriteIntPtr(strName, Marshal.StringToBSTR("_constantFieldId" + fieldId)); } if (strDocString != IntPtr.Zero) { RdMarshal.WriteIntPtr(strDocString, IntPtr.Zero); } if (dwHelpContext != IntPtr.Zero) { RdMarshal.WriteInt32(dwHelpContext, 0); } if (strHelpFile != IntPtr.Zero) { RdMarshal.WriteIntPtr(strHelpFile, IntPtr.Zero); } return((int)KnownComHResults.S_OK); } if (memid == (int)KnownDispatchMemberIDs.MEMBERID_NIL) { // return the cached information here, to workaround the VBE bug for unnamed UserForm base classes causing an access violation if (strName != IntPtr.Zero) { RdMarshal.WriteIntPtr(strName, RdMarshal.StringToBSTR(Name)); } if (strDocString != IntPtr.Zero) { RdMarshal.WriteIntPtr(strDocString, RdMarshal.StringToBSTR(DocString)); } if (dwHelpContext != IntPtr.Zero) { RdMarshal.WriteInt32(dwHelpContext, HelpContext); } if (strHelpFile != IntPtr.Zero) { RdMarshal.WriteIntPtr(strHelpFile, RdMarshal.StringToBSTR(HelpFile)); } return((int)KnownComHResults.S_OK); } else { var hr = _target_ITypeInfo.GetDocumentation(memid, strName, strDocString, dwHelpContext, strHelpFile); return(ComHelper.HRESULT_FAILED(hr) ? HandleBadHRESULT(hr) : hr); } }
public override int GetTypeInfoType(int index, IntPtr pTKind) { if (index >= _containedTypeInfos.Count) { return((int)KnownComHResults.TYPE_E_ELEMENTNOTFOUND); } var ti = _containedTypeInfos[index]; var typeKind = TypeInfoWrapper.PatchTypeKind(ti.TypeKind); RdMarshal.WriteInt32(pTKind, (int)typeKind); return((int)KnownComHResults.S_OK); }
public override int GetTypeInfoType(int index, IntPtr pTKind) { var hr = _target_ITypeLib.GetTypeInfoType(index, pTKind); if (ComHelper.HRESULT_FAILED(hr)) { return(HandleBadHRESULT(hr)); } var tKind = RdMarshal.ReadInt32(pTKind); tKind = (int)TypeInfoWrapper.PatchTypeKind((TYPEKIND_VBE)tKind); RdMarshal.WriteInt32(pTKind, tKind); return(hr); }
public override int GetContainingTypeLib(IntPtr ppTLB, IntPtr pIndex) { // even though pIndex is described as a non-optional OUT argument, mscorlib sometimes calls this with a nullptr from the C++ side. if (pIndex == IntPtr.Zero) { RdMarshal.WriteIntPtr(ppTLB, IntPtr.Zero); return((int)KnownComHResults.E_INVALIDARG); } RdMarshal.WriteIntPtr(ppTLB, RdMarshal.GetComInterfaceForObject(_container, typeof(ITypeLibInternal))); if (pIndex != IntPtr.Zero) { RdMarshal.WriteInt32(pIndex, ContainerIndex); } return((int)KnownComHResults.S_OK); }
public override int GetNames(int memid, IntPtr rgBstrNames, int cMaxNames, IntPtr pcNames) { if (IsDispatchMemberIDInOurConstantsRange(memid)) { // this is most likely one of our simulated names from GetVarDesc() var fieldId = memid & _ourConstantsDispatchMemberIDIndexBitmask; if ((rgBstrNames != IntPtr.Zero) && (cMaxNames >= 1)) { // output 1 string to the array RdMarshal.WriteIntPtr(rgBstrNames, RdMarshal.StringToBSTR("_constantFieldId" + fieldId)); if (pcNames != IntPtr.Zero) { RdMarshal.WriteInt32(pcNames, 1); } return((int)KnownComHResults.S_OK); } } var hr = _target_ITypeInfo.GetNames(memid, rgBstrNames, cMaxNames, pcNames); return(ComHelper.HRESULT_FAILED(hr) ? HandleBadHRESULT(hr) : hr); }