分析二进制属性来读取 TZREG 结构的流
本主题演示如何从存储在二进制属性 PidLidTimeZoneStruct 中的持久格式读取 TZREG 结构。
TZREG* BinToTZREG(ULONG cbReg, LPBYTE lpbReg)
{
if (!lpbReg) return NULL;
// Update this if parsing code is changed.
if (cbReg < 3*sizeof(long) + 2*sizeof(WORD) + 2*sizeof(SYSTEMTIME)) return NULL;
TZREG tzReg = {0};
LPBYTE lpPtr = lpbReg;
tzReg.lBias = *((long*)lpPtr);
lpPtr += sizeof(long);
tzReg.lStandardBias = *((long*)lpPtr);
lpPtr += sizeof(long);
tzReg.lDaylightBias = *((long*)lpPtr);
lpPtr += sizeof(long);
lpPtr += sizeof(WORD);// reserved
tzReg.stStandardDate = *((SYSTEMTIME*)lpPtr);
lpPtr += sizeof(SYSTEMTIME);
lpPtr += sizeof(WORD);// reserved
tzReg.stDaylightDate = *((SYSTEMTIME*)lpPtr);
lpPtr += sizeof(SYSTEMTIME);
TZREG* ptzReg = NULL;
ptzReg = new TZREG;
if (ptzReg)
{
*ptzReg = tzReg;
}
return ptzReg;
}