Beispiel #1
0
        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);
        }