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 |
|
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 |
|
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. |
|
Spiros Nikolopoulos
Guest
|
Hi Dmitry,
Thanks for yor reply.
A value of a particular property by its name. |
|
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. |
|
Spiros Nikolopoulos
Guest
|
|