简单的保护数据你可以使用CriticalSection.
For example:
CRITICAL_SECTION lock; //定义一把锁
InitializeCriticalSection(&lock); //初始化锁
EnterCriticalSection(&lock); //获得互斥锁
//put the operations here
//the code here may be accessed by multi thread
//and multi thread are synchronized and willn't damage the data
LeaveCriticalSection(&lock);//释放互斥锁