Using the CEVT_BLOB Property Data Type

< BACK  NEXT >
[oR]

The CEVT_BLOB data type allows binary data to be stored in a single property value in a database record up to a maximum length of 64 KB. The CEPROP-VAL structure's val union member for BLOBs is 'blob', and this is a CEBLOB structure:

 typedef struct _CEBLOB {     DWORD           dwCount;     LPBYTE          lpb; } CEBLOB; 

The dwCount member contains the number of bytes to store in the property, and lpb points to the data to be written. The following code fragments show code that has been added to Listings 4.7 and 4.8 to write and read a timestamp that records the time when the record was written. First, a new property identifier is declared.

 const CEPROPID propTimeStamp = MAKELONG(CEVT_BLOB, 103); 

The property value specifies the property identifier (propTimeStamp), and a CEBLOB structure. The CEBLOB members contain the number of bytes of data to write (which is the size of the structure), and a pointer to the data to be written.

 propval[3].propid = propTimeStamp; propval[3].val.blob.dwCount = sizeof(sysTime); propval[3].val.blob.lpb = (LPBYTE)&sysTime; 

Reading the BLOB data is straightforward the property returned from calling CeReadRecordPropsEx contains the CEBLOB structure.

   case propTimeStamp:     LPSYSTEMTIME lpSysTime =       (LPSYSTEMTIME)props[i].val.blob.lpb;     cout   _T(" Record written at:")            lpSysTime->>wHour   _T(":")            lpSysTime->>wMinute   _T(":")            lpSysTime->>wSecond   _T(":")            lpSysTime->>wMilliseconds;     LocalFree(lpSysTime);     break; 

It is important to note that you are responsible for the data pointed to by the CEBLOB lpb pointer. When calling CeWriteRecordProps you should free the data pointed to by lpb in the sample above, the structure sysTime is an auto variable that is deleted automatically when the function returns. Note that LocalFree is called on lpSysTime after the data returned from CeReadRecordPropsEx has been used.


< BACK  NEXT >


Windows CE 3. 0 Application Programming
Windows CE 3.0: Application Programming (Prentice Hall Series on Microsoft Technologies)
ISBN: 0130255920
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net