從約會讀取時區屬性
本主題顯示會呼叫 和 這兩個函 BinToTZDEFINITION
BinToTZREG
式的函ReadTimeZones
式,以從約會讀取時區屬性 PidLidAppointmentTimeZoneDefinitionStartDisplay 和 PidLidTimeZoneStruct。
PidLidAppointmentTimeZoneDefinitionStartDisplay 包含對應至 TZDEFINITION 結構之保存格式的數據流,而 PidLidTimeZoneStruct 包含對應至 TZREG 結構保存格式的數據流。 若要取得確切的 TZDEFINITION 和 TZREG 結構, BinToTZDEFINITION
並 BinToTZREG
用來適當地剖析這些屬性的數據流值。 這兩個函式定義於 從二進位屬性剖析數據流以讀取 TZDEFINITION 結構 ,以及 分別從二進位屬性剖析數據流以讀取 TZREG 結構。
void ReadTimeZones(LPMAPIPROP lpAppointment)
{
HRESULT hRes = S_OK;
LPSPropTagArray lpNamedPropTags = NULL;
MAPINAMEID NamedID[2] = {0};
LPMAPINAMEID lpNamedID[2];
lpNamedID[0] = &NamedID[0];
lpNamedID[1] = &NamedID[1];
NamedID[0].lpguid = (LPGUID)&PSETID_Appointment;
NamedID[0].ulKind = MNID_ID;
NamedID[0].Kind.lID = dispidTimeZoneStruct;
NamedID[1].lpguid = (LPGUID)&PSETID_Appointment;
NamedID[1].ulKind = MNID_ID;
NamedID[1].Kind.lID = dispidApptTZDefStartDisplay;
hRes = lpAppointment->GetIDsFromNames(
2,
lpNamedID,
NULL,
&lpNamedPropTags);
if (SUCCEEDED(hRes) && lpNamedPropTags)
{
SizedSPropTagArray(2,sptaTzProps) = {2,
CHANGE_PROP_TYPE(lpNamedPropTags->aulPropTag[0],PT_BINARY),
CHANGE_PROP_TYPE(lpNamedPropTags->aulPropTag[1],PT_BINARY),
};
LPSPropValue lpProps = NULL;
ULONG cProps = 0;
hRes = lpAppointment->GetProps(
(LPSPropTagArray)&sptaTzProps,
NULL,
&cProps,
&lpProps);
if (SUCCEEDED(hRes) && 2 == cProps && lpProps)
{
if (PT_BINARY == PROP_TYPE(lpProps[0].ulPropTag))
{
TZREG* ptzReg = BinToTZREG(lpProps[0].Value.bin.cb,lpProps[0].Value.bin.lpb);
// TODO: Do whatever is necessary with ptzReg.
delete ptzReg;
}
if (PT_BINARY == PROP_TYPE(lpProps[1].ulPropTag))
{
TZDEFINITION* ptzDef = BinToTZDEFINITION(lpProps[1].Value.bin.cb,lpProps[1].Value.bin.lpb);
// TODO: Do whatever is necessary with ptzDef.
delete[] ptzDef;
}
}
MAPIFreeBuffer(lpProps);
}
MAPIFreeBuffer(lpNamedPropTags);
}