从约会中读取时区属性

本主题演示一个函数 , ReadTimeZones该函数调用两个函数 BinToTZDEFINITIONBinToTZREG,以从约会中读取时区属性 PidLidAppointmentTimeZoneDefinitionStartDisplayPidLidTimeZoneStruct

PidLidAppointmentTimeZoneDefinitionStartDisplay 包含映射到 TZDEFINITION 结构的持久格式的流, PidLidTimeZoneStruct 包含映射到 TZREG 结构的持久格式的流。 获取确切的 TZDEFINITIONTZREG 结构, BinToTZDEFINITIONBinToTZREG 用于适当分析这些属性的流值。 这两个函数分别在 分析二进制属性中的流以读取 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); 
}

另请参阅