GetPropInfo of _ContactItem

Add-in Express™ Support Service
That's what is more important than anything else

GetPropInfo of _ContactItem
 
Spiros Nikolopoulos


Guest


Is It possible to get PropInfo of a _ContactItem ?
I whant to get all _ContactItem properties with



   function GetProp(AComp: TComponent; APropName: string):string;
      var
         TypeInf: PTypeInfo;
         PropInfo: PPropInfo;

      begin
         TypeInf := AComp.ClassInfo;
         PropInfo := GetPropInfo(TypeInf, APropName);
         Result := GetStrProp(AComp, PropInfo);
      end;

     

      GetProp( TComponent(iName.IContact), <Property Name> )


But I get an AV in TypeInf := AComp.ClassInfo;

Thanks
Posted 04 Dec, 2012 04:17:02 Top
Spiros Nikolopoulos


Guest


Sorry for the post _ContactItem is IDispatch I have to use Invoke like:


 function GetProp(dispobj: IDispatch; PropertyName: WideString):Variant;
    var hr: HRESULT;
        iDispId: integer;
        value: Variant;
        params: TDispParams;
    begin
      hr:=dispobj.GetIDsOfNames(GUID_NULL,@PropertyName, 1, LOCALE_SYSTEM_DEFAULT, @iDispId);
      hr:=dispobj.Invoke(iDispId,GUID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_PROPERTYGET,Params,@Value,nil,nil);
      Result:=Value;
    end;


but now I always get empty result anyone knows why?
Thanks
Posted 04 Dec, 2012 04:59:57 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Spiros,

Sorry, I do not quite understand what you are trying to do. Do you need to get all names of all properties or get a value of a particular property by its name? Please clarify.
Posted 04 Dec, 2012 10:47:14 Top
Spiros Nikolopoulos


Guest


Hi Dmitry,
Thanks for yor reply.
A value of a particular property by its name.
Posted 04 Dec, 2012 10:53:35 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Spiros,

Thank you. I have just tested the following code on my machine, it works:


procedure TAddInModule.adxRibbonTab1Controls0Controls0Click(
  Sender: TObject; const RibbonControl: IRibbonControl);
var
  IContact: _ContactItem;
  Value: WideString;
begin
  OutlookApp.ActiveInspector().CurrentItem.QueryInterface(IID__ContactItem, IContact);
  if Assigned(IContact) then begin
    Value := GetProperty(IContact, 'Email1Address');
    ShowMessage(Value);
  end;
end;

function TAddInModule.GetProperty(obj: IDispatch; PropertyName: WideString): OleVariant;
var
  hr: HRESULT;
  DispId: Integer;
  Value: OleVariant;
  Params: TDispParams;
begin
  Result := '';
  hr := obj.GetIDsOfNames(GUID_NULL, @PropertyName, 1, 0, @DispId);
  if (hr = S_OK) then begin
    Params.cArgs := 0;
    Params.cNamedArgs := 0;
    Params.rgvarg := nil;
    Params.rgdispidNamedArgs := nil;
    hr := obj.Invoke(DispId, GUID_NULL, 0, DISPATCH_PROPERTYGET, Params, @Value, nil, nil);
    if (hr = S_OK) then
      Result := Value;
  end;
end;


Note, I have accessed and retrieved a value from the standard Email1Address property.
Posted 04 Dec, 2012 11:34:34 Top
Spiros Nikolopoulos


Guest


That works !
Thanks
Posted 05 Dec, 2012 09:08:55 Top