Question

I have this working piece of code accessing an Outlook AppointmentItem.PropertyAccessor.GetProperties method:

var
  lPropertyAccessor: OLEVariant;
  lDT              : TDateTime;
  lSchemas, lValues: Variant;

lPropertyAccessor := AAppointmentItem.PropertyAccessor;
lSchemas := VarArrayOf([cPublicStringNameSpace + PROPERTY_TIMETELLID + 'fail',
                        cPublicStringNameSpace + PROPERTY_TIMETELLSYNCTIME,
                        cPublicStringNameSpace + PROPERTY_TIMETELLSYNCID]);
try
  lValues := lPropertyAccessor.GetProperties(lSchemas);
  lEvent.CustSyncTTID := lValues[0];
  lDT := lValues[1];
  lDT := TTimeZone.Local.ToLocalTime(lDT);
  lEvent.CustSyncDate := lDT;
  lEvent.CustSyncEntryID := lValues[2];
except
end;

I am causing this to fail for the first array entry (" + 'fail' "), because I want to test what the documentation says:
If an error occurs for getting a specific property, the Err value will be returned in the corresponding location in the returned array.

After calling GetProperties, according to the inspector window, lValues[0] contains: Error(-2147221233).

I have tried to find a Windows named constant with this value so that I can test against it (if lValues[0] <> MagicalWindowsConst then...), but I can't find it or its hex equivalent FFFFFFFF8004010F (not even in the Embarcadero source files).

If I let the code continue, the integer assignment for lEvent.CustSyncTTID gives:
'Could not convert variant of type (Error) into type (Integer)'

That would suggest there is some 'error' variant type??? I can't find that either.

I tried defining const cErr = -2147221233 or const cErr : Int64 = -2147221233 but that gives me an Invalid Variant Operation error on the if lValues[0] <> cErr.

What can I test against to determine if the array element returns the error code?

Was it helpful?

Solution

I found it:

I can test if VarType(lValues[0]) <> varError

So I obviously overlooked that there is a varError type

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top